Skip to content

Non-descriptive error message if webpack.config.js is invalid #7472

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

Closed
Artur- opened this issue Feb 3, 2020 · 6 comments
Closed

Non-descriptive error message if webpack.config.js is invalid #7472

Artur- opened this issue Feb 3, 2020 · 6 comments

Comments

@Artur-
Copy link
Member

Artur- commented Feb 3, 2020

Take the Spring Boot starter project and replace webpack.config.js with

foo

If you run node_modules/.bin/webpack manually, you will get

ReferenceError: foo is not defined
    at Object.<anonymous> (.../webpack.config.js:1:63)

If you run mvn, you get

2020-02-03 12:15:47.107 ERROR 60528 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Exception sending context initialized event to listener instance of class [com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener]

java.lang.RuntimeException: Unable to initialize Vaadin DevModeHandler
	at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:349) ~[vaadin-spring-12.2.0.alpha1.jar:na]
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4680) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5143) [tomcat-embed-core-9.0.22.jar:9.0.22]
...
Caused by: java.lang.IllegalStateException: Webpack exited prematurely
	at com.vaadin.flow.server.DevModeHandler.<init>(DevModeHandler.java:201) ~[flow-server-2.2.0.alpha10.jar:2.2.0.alpha10]
	at com.vaadin.flow.server.DevModeHandler.createInstance(DevModeHandler.java:298) ~[flow-server-2.2.0.alpha10.jar:2.2.0.alpha10]
	at com.vaadin.flow.server.DevModeHandler.start(DevModeHandler.java:248) ~[flow-server-2.2.0.alpha10.jar:2.2.0.alpha10]

This does not even contain a reference to webpack.config.js nor to the problem that actually occured in webpack

@caalador
Copy link
Contributor

caalador commented Feb 4, 2020

It does say Webpack exited prematurely, is there any more log before the illegal state?

Also as you replaced the config content with foo up in the logs do you have:

"Flow generated webpack configuration was not mentioned "
"in the configuration file: {}."
"Please verify that './webpack.generated.js' is used "
"in the merge or remove the file to generate a new one."

@mvysny
Copy link
Member

mvysny commented Apr 8, 2021

Same thing here with Vaadin 14.5.1: I only see the exception but there is no indication in the entire stdout as to why the webpack would fail:

Caused by: java.lang.IllegalStateException: Webpack exited prematurely
        at com.vaadin.flow.server.DevModeHandler.doStartWebpack(DevModeHandler.java:657)
        at com.vaadin.flow.server.DevModeHandler.doStartDevModeServer(DevModeHandler.java:583)
        at com.vaadin.flow.server.DevModeHandler.runOnFutureComplete(DevModeHandler.java:530)
        at com.vaadin.flow.server.DevModeHandler.lambda$new$0(DevModeHandler.java:146)
        at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)

This started to happen after I applied the checker from #8475 . Without the checker the Vaadin would fail in runtime with Uncaught DOMException: CustomElementRegistry.define: 'vaadin-lumo-styles' has already been defined as a custom element: the checker apparently catches the issue early on (which is a good thing), but then Vaadin logs nothing of the issue and fails with this useless exception.

This is a horrible dev UX experience - my project doesn't start anymore, and I have no idea why. I would rather revert the checker and go back to failing at runtime, at least there I'll receive an "informative" error message.

@caalador
Copy link
Contributor

Is this only in v14 dev mode server start?
For v19+ there is the server output when running the server (both plain and spring starter):

[INFO]  com.vaadin.flow.server.DevModeHandler    : Running webpack to compile frontend resources. This may take a moment, please stand by...
...\skeleton-starter-flow\webpack.config.js:1
foo
^

ReferenceError: foo is not defined
    at Object.<anonymous> (...\skeleton-starter-flow\webpack.config.js:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at WEBPACK_OPTIONS (...\skeleton-starter-flow\node_modules\.pnpm\[email protected][email protected]\node_modules\webpack-cli\bin\utils\convert-argv.js:114:13)
    at requireConfig (...\skeleton-starter-flow\node_modules\.pnpm\[email protected][email protected]\node_modules\webpack-cli\bin\utils\convert-argv.js:116:6)
    at ...\skeleton-starter-flow\node_modules\.pnpm\[email protected][email protected]\node_modules\webpack-cli\bin\utils\convert-argv.js:123:17

@mvysny
Copy link
Member

mvysny commented Apr 13, 2021

@caalador could be - I've only tested Vaadin 14.5.1.

caalador added a commit that referenced this issue Apr 13, 2021
Log as error any output from webpack when
webpack exits prematurely.

Closes #7472
pleku pushed a commit that referenced this issue Apr 13, 2021
Log as error any output from webpack when webpack exits prematurely without success/failure.

Closes #7472
ZheSun88 pushed a commit that referenced this issue Apr 14, 2021
Log as error any output from webpack when webpack exits prematurely without success/failure.

Closes #7472
vaadin-bot pushed a commit that referenced this issue Apr 15, 2021
Log as error any output from webpack when webpack exits prematurely without success/failure.

Closes #7472
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 14.6.0.beta2. For prerelease versions, it will be included in its final version.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 14.5.3. For prerelease versions, it will be included in its final version.

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

No branches or pull requests

5 participants