Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Logs spammed on console in production #111

Closed
mathewcst opened this issue Mar 25, 2024 · 3 comments
Closed

[Bug]: Logs spammed on console in production #111

mathewcst opened this issue Mar 25, 2024 · 3 comments
Assignees
Labels
bug Something isn't working triage New issues get this label, remove it after triage

Comments

@mathewcst
Copy link

mathewcst commented Mar 25, 2024

Provide environment information

NextJS 14.1

Which project is this issue for?

@serwist/next

Link to reproduction - Issues with a link to complete (but minimal) reproduction code help us address them faster

https://lostark.party/

To reproduce

Created a NextJS app and used the following setting:

import { defaultCache } from "@serwist/next/browser";
import { installSerwist } from "@serwist/sw";

import type { PrecacheEntry } from "@serwist/precaching";

declare const self: ServiceWorkerGlobalScope & {
  // Change this attribute's name to your `injectionPoint`.
  __SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
};

// Anything random.
const revision = crypto.randomUUID();

installSerwist({
  precacheEntries: self.__SW_MANIFEST,
  skipWaiting: true,
  clientsClaim: true,
  navigationPreload: true,
  runtimeCaching: defaultCache,
  disableDevLogs: true,
  fallbacks: {
    entries: [
      {
        url: "/~offline",
        revision,
        matcher({ request }) {
          // Or whatever else you want to check for in a request.
          return request.destination === "document";
        },
      },
    ],
  },
});

Describe the bug

Although disableDevLogs is set to true, on production, the app spams console logs with serwist info

Expected behavior

To not have any logs on production

Screenshots (if relevant)

image

Additional information (if relevant)

Can be viewed on: https://lostark.party

@mathewcst mathewcst added bug Something isn't working triage New issues get this label, remove it after triage labels Mar 25, 2024
@mathewcst
Copy link
Author

Found a mode on withSerwistInit, although setting it to production the problem presists.

const withSerwist = withSerwistInit({
  cacheOnFrontEndNav: true,
  swSrc: "src/sw.ts",
  swDest: "public/sw.js",
  swUrl: "/sw.js",
  reloadOnOnline: true,
  mode: "production",
  exclude: [
    /\/.*.(js|css).map\//,
    /\.map$/,
    /^manifest.*\.js$/,
    "/api/event",
    "/js/script.js",
  ],
  additionalPrecacheEntries: [],
  disable: process.env.NODE_ENV === "development",
});

@mathewcst
Copy link
Author

Ok, found the problem, we can close this now.

Somehow I uploaded a sw.js built in development to production.

@DuCanhGH
Copy link
Member

@mathewcst 💀

How is that supposed to happen...

Also, mode doesn't do anything and will be gone in v9.0.0 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues get this label, remove it after triage
Projects
None yet
Development

No branches or pull requests

2 participants