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

Reloading error sometimes #1710

Closed
drager opened this issue Jul 9, 2022 · 10 comments · Fixed by #1711
Closed

Reloading error sometimes #1710

drager opened this issue Jul 9, 2022 · 10 comments · Fixed by #1711

Comments

@drager
Copy link

drager commented Jul 9, 2022

I'm not sure if this is a bug with hot reloading or not, but sometimes I'm getting the following error (happens a lot when I make some larger code changes).

 Build  [=============       ] 65% (19.3s) building<i> [webpack-dev-middleware] wait until bundle finished: /backtester
 Build  [==================  ] 90% (37.8s) additional chunk assets processing<e> [webpack-dev-middleware] TypeError: Cannot read property '_value' of undefined
<e>     at module.exports (/home/drager/development/tinker/tinker-web-app/node_modules/preact-cli/lib/lib/webpack/create-load-manifest.js:10:52)
<e>     at /home/drager/development/tinker/tinker-web-app/node_modules/preact-cli/lib/lib/webpack/push-manifest.js:12:22
<e>     at _next1 (eval at create (/home/drager/development/tinker/tinker-web-app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
<e>     at eval (eval at create (/home/drager/development/tinker/tinker-web-app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:51:1)
<e>     at emit (/home/drager/development/tinker/tinker-web-app/node_modules/fork-ts-checker-webpack-plugin/lib/index.js:274:17)
<e>     at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/drager/development/tinker/tinker-web-app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:47:1)
<e>     at Compiler.emitAssets (/home/drager/development/tinker/tinker-web-app/node_modules/webpack/lib/Compiler.js:491:19)
<e>     at onCompiled (/home/drager/development/tinker/tinker-web-app/node_modules/webpack/lib/Watching.js:51:19)
<e>     at /home/drager/development/tinkertinker-web-app/node_modules/webpack/lib/Compiler.js:681:15
<e>     at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/drager/development/tinker/tinker-web-app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
<e>     at /home/drager/development/tinker/tinker-web-app/node_modules/webpack/lib/Compiler.js:678:31
<e>     at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/drager/development/tinker/tinker-web-app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
<e>     at AsyncSeriesHook.lazyCompileHook (/home/drager/development/tinker/tinker-web-app/node_modules/tapable/lib/Hook.js:154:20)
<e>     at /home/drager/development/tinker/tinker-web-app/node_modules/webpack/lib/Compilation.js:1423:35
<e>     at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/drager/development/tinker/tinker-web-app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
<e>     at AsyncSeriesHook.lazyCompileHook (/home/drager/development/tinker/tinker-web-app/node_modules/tapable/lib/Hook.js:154:20)
Environment Info:
  System:
    OS: Linux 5.3 Ubuntu 18.04.6 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i5-4690K CPU @ 3.50GHz
  Binaries:
    Node: 16.4.0 - ~/.nvm/versions/node/v16.4.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.4.0/bin/yarn
    npm: 7.18.1 - ~/.nvm/versions/node/v16.4.0/bin/npm
  Browsers:
    Chrome: 103.0.5060.114
    Firefox: 102.0
  npmPackages:
    preact: ^10.3.1 => 10.9.0 
    preact-cli: ^3.4.0 => 3.4.0 
    preact-render-to-string: ^5.1.4 => 5.2.0 
    preact-router: ^4.0.1 => 4.0.1 
@rschristian
Copy link
Member

Hm, looks to be a race condition with the asset manifest being generated:

assets = JSON.parse(assets['asset-manifest.json']._value);

Preloading is prod-only, so that plugin should probably only be returning an empty object in dev.

@drager
Copy link
Author

drager commented Jul 9, 2022

Hmm ok. I'm running via preact watch --refresh --port 3000".

@rschristian
Copy link
Member

rschristian commented Jul 9, 2022

Let me know if you can reliably reproduce it, though I somewhat doubt that's possible. I assume another save/HMR tick fixes this?

I think an early return is all that's needed there, will try to get something together tomorrow.

Edit: Put a PR together. If you are willing, try applying the changes with something like patch-package and let me know how it goes.

@drager
Copy link
Author

drager commented Jul 9, 2022

Let me know if you can reliably reproduce it, though I somewhat doubt that's possible. I assume another save/HMR tick fixes this?

I think an early return is all that's needed there, will try to get something together tomorrow.

Yeah, not sure how to cause it. Seems to happen more when I have code that contains errors... I actually need to restart the whole dev server to get it working again. It hangs for me...

I'll try using patch-package. Thanks!

@drager
Copy link
Author

drager commented Jul 9, 2022

Used the patch for 1 hour now and didn't get any errors for this hour. Without the patch I got the error every now and then, so it seems to be working 🎉

@egilll
Copy link

egilll commented Jul 21, 2022

I get this error every single time I introduce a TypeScript error (but only if Preact CLI has been running for a while; it does not appear when it's only been running for a few minutes).

My guess was therefore that this had something to do with the output from fork-ts-checker-webpack-plugin messing with the next plugin, even though that would be very strange behavior.

The error is not resolved by saving files again, instead I need to restart Preact CLI each time. In the meantime, Preact CLI will serve the old files, which is often quite confusing.

(I am running Preact Cli 3.4.0, TypeScript 3.9.9)

@rschristian
Copy link
Member

TS errors have no impact on the dev server, no. Syntax errors in TS might, depending on the specific syntax issue.

Preact CLI will serve the old files, which is often quite confusing.

webpack-dev-server will. If the rebuild fails, it continues to server old content. I'm not aware of any way to configure this, but we do expose the entire Webpack config for you to do so if that is in fact possible.

@Julioevm
Copy link

I'm having the same issue

@oliverfindl
Copy link

Hello,

I'm also having this same issue.

Environment Info:
  System:
    OS: Linux 4.15 Ubuntu 16.04.7 LTS (Xenial Xerus)
    CPU: (4) x64 Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
  Binaries:
    Node: 17.9.0 - /usr/bin/node
    Yarn: 1.22.15 - /usr/bin/yarn
    npm: 8.8.0 - /usr/bin/npm
  Browsers:
    Chrome: 103.0.5060.134
    Firefox: 88.0
  npmPackages:
    preact: ^10.6.6 => 10.10.0
    preact-cli: ^3.4.0 => 3.4.0
    preact-render-to-string: ^5.1.20 => 5.2.1
    preact-router: ^4.0.1 => 4.1.0 

I can consistently reproduce it by re-declaring some type, e.g.:

type Test1 = any;
type Test1 = any;

Which throws kinda standard type error and after I fix it, e.g.:

type Test1 = any;
type Test2 = any;

Then Webpack hangs with error:

[webpack-dev-middleware] TypeError: Cannot read properties of undefined (reading '_value')
<e>     at module.exports (.../node_modules/preact-cli/lib/lib/webpack/create-load-manifest.js:10:52)
<e>     at .../node_modules/preact-cli/lib/lib/webpack/push-manifest.js:12:22
<e>     at _next1 (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
<e>     at eval (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:51:1)
<e>     at emit (.../node_modules/fork-ts-checker-webpack-plugin/lib/index.js:274:17)
<e>     at AsyncSeriesHook.eval [as callAsync] (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:47:1)
<e>     at Compiler.emitAssets (.../node_modules/webpack/lib/Compiler.js:491:19)
<e>     at onCompiled (.../node_modules/webpack/lib/Watching.js:51:19)
<e>     at .../node_modules/webpack/lib/Compiler.js:681:15
<e>     at AsyncSeriesHook.eval [as callAsync] (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
<e>     at .../node_modules/webpack/lib/Compiler.js:678:31
<e>     at AsyncSeriesHook.eval [as callAsync] (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
<e>     at AsyncSeriesHook.lazyCompileHook (.../node_modules/tapable/lib/Hook.js:154:20)
<e>     at .../node_modules/webpack/lib/Compilation.js:1423:35
<e>     at AsyncSeriesHook.eval [as callAsync] (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
<e>     at AsyncSeriesHook.lazyCompileHook (.../node_modules/tapable/lib/Hook.js:154:20)

And won't reload itself after another change. It needs to be killed and started again.

Fix mentioned above solves this issue for me.

Thanks.

@rschristian
Copy link
Member

Fix released in v3.4.1.

Let me know if anyone still has any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants