question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PackFileCacheStrategy warnings with global Promise hook

See original GitHub issue

Bug report

What is the current behavior?

I was runing a nextjs project with webpack5. When I added following code

class HookPromise extends Promise {}
global.Promise = HookPromise

I got some warnings like

<w> [webpack.cache.PackFileCacheStrategy] Restoring failed for Compilation/codeGeneration|external "@babel/runtime-corejs2/core-js/parse-int"|webpack-runtime from pack: Error: A lazy value that has been unmemorized can't be called again
<w> [webpack.cache.PackFileCacheStrategy] Restoring failed for Compilation/codeGeneration|external "next/dist/server/image-config.js"|webpack-runtime from pack: Error: A lazy value that has been unmemorized can't be called again
<w> [webpack.cache.PackFileCacheStrategy] Restoring failed for Compilation/codeGeneration|external "next/dist/shared/lib/to-base-64.js"|webpack-runtime from pack: Error: A lazy value that has been unmemorized can't be called again
<w> [webpack.cache.PackFileCacheStrategy] Restoring failed for Compilation/assets|chunkpages/blog from pack: Error: A lazy value that has been unmemorized can't be called again

If the current behavior is a bug, please provide the steps to reproduce.

see above

What is the expected behavior?

in lib/cache/PackFileCacheStrategy.js:

if (value instanceof Promise) {
  ...
}

I changed the conditional statement, the warnings were disappeared

if (value && typeof value.then === 'function') {
  ...
}

Other relevant information: nextjs version: 11.1.2 webpack version: nextjs bundled version Node.js version: 14.16.0 Operating System: mac os 11.4 Additional tools:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Oct 1, 2021

Yes, PR welcome

0reactions
alexander-akaitcommented, Oct 1, 2021

Example of fix inside the issue, we should change value instanceof Promise on value && typeof value.then === 'function'

Read more comments on GitHub >

github_iconTop Results From Across the Web

<w> [webpack.cache.PackFileCacheStrategy] Caching failed ...
Simply creating a new Next.js project and running yarn dev / npm run dev logs the following warning in the console: [webpack.cache.PackFileCacheStrategy] ...
Read more >
Cache - webpack
warning. The final location of the cache is a combination of cache.cacheDirectory + cache.name . cache.cacheLocation. string. Locations for the cache.
Read more >
webpack/webpack - Gitter
Hi! I am facing some issue with webpack. I am working setting up a javascript development environment. I used extract-text-plugin in my webpack.config.prod....
Read more >
I'm having this weird webpack.cache.PackageCacheStrategy
Here is global.scss mentioned in the error. When I try to removed the tailwind imports, it compiles without a problem. But I needed...
Read more >
Writing a React hook to cancel promises when a component ...
I love how hooks let you write clean React code. Here is how you would use a cancelable promise hook inside a functional...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found