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.

bug: Storybook@4.1.x swallows errors from the compiler

See original GitHub issue

In case there are some errors during compilation (in my case that was Manager Compiler), e.g.:

Module not found: Error: Can’t resolve ‘child_process’ in …

or

Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type.

core/server/dev-server will reject with Stats instance, but core/server/build-dev won’t show any errors, because it expects Error instance. As a result storybook execution will hang forever without any error messages:

info @storybook/react v4.1.11
info
info => Loading static files from: ~/foo/public .
info => Loading presets
info => Loading presets
info => Loading custom addons config.
info => Using base config because react-scripts is not installed.
info => Loading custom webpack config (extending mode).
webpack built 16bec9665459b26d1ce2 in 29388ms

To Reproduce

Steps to reproduce the behavior:

a. Create some file e.g. foo.unknown and try to import it in your code b. Try to import child_process

Expected behavior

a. We should get an error complaining about lacking loader b. We should get an error, that webpack can not resolve the module

Code snippets

Possible solution is to improve error handling here:

https://github.com/storybooks/storybook/blob/v4.1.11/lib/core/src/server/build-dev.js#L285-L290

We can test for Stats object (I don’t know whether is better to test for interface or add instanceof check):

  } catch (error) {
    if (error instanceof Error) {
      logger.error(error);
    } else if (error && error.hasErrors && error.hasErrors()) {
      // Stats with errors
      logger.error(error.toJson().errors.slice(0, 5).join("\n\n"));
    }
    if (options.smokeTest) {
      process.exit(1);
    }
  }

Another possible solution is to rewrite promises in core/src/server/dev-server.js so that they always return Error instances (but in this case I’ve got problems with output formatting. Logger converts error instance into json without line breaks)

System:

  • OS: Ubuntu 18.04
  • Framework: React
  • Version: 4.1.11

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
SleepWalkercommented, Mar 2, 2019

@shilman yep, it is fixed in v5.

0reactions
shuieryincommented, Feb 18, 2020

I got the same issue on v5.3.13, seems the bug reappear again?

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: Storybook@4.1.x swallows errors from the compiler #5584
In case there are some errors during compilation (in my case that was Manager Compiler), e.g.: Module not found: Error: Can't resolve ...
Read more >
Android databinding swallows errors from other compilers
The problem is that the compilation error isnt related to databinding at all, and as such I have no idea whats actually causing...
Read more >
Spinnaker Release 1.23.0
Spinnaker will now overwrite images in a manifest with a bound artifact if the input manifest's image has a tag on it. The...
Read more >
Swallow Barn, or A Sojourn in the Old Dominion. In Two ...
Encountered typographical errors have been preserved, and appear in red type. Any hyphens occurring in line breaks have been removed, and the trailing...
Read more >
Roser, Nancy L,, Ed. TITLE Adventuring with Books - ERIC
ABSTRACT. Designed to help teachers, librarians, arid parents introduce books of exceptional literary and artistic merit, accuracy,.
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