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

Dev errors getting swallowed #20161

Closed
shilman opened this issue Dec 8, 2022 · 4 comments
Closed

Dev errors getting swallowed #20161

shilman opened this issue Dec 8, 2022 · 4 comments

Comments

@shilman
Copy link
Member

shilman commented Dec 8, 2022

When running in dev mode, some errors are getting swallowed with the following error message:

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "[object Object]".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

This code is breaking:

https://github.com/storybookjs/storybook/blob/next/code/lib/cli/src/dev.ts#L20-L35

The weird error handling code is to deal with errors being thrown OR a webpack Stats object being throw, and the code used to be

await buildDevStandalone(options);

However, a recent update changed the code to:

await withTelemetry('dev', { presetOptions: options }, () => buildDevStandalone(options));

Wrapping the calling code in withTelemetry somehow leads to the error getting unhandled. Although how this happens is unclear.

@shilman
Copy link
Member Author

shilman commented Dec 8, 2022

We found that the culprit was the following two lines.

A direct access to the cache:

(await cache.get('enableCrashReports')) ?? (await cache.get('enableCrashreports'));

A call to a function that accesses the cache:

const precedingUpgrade = await getPrecedingUpgrade();

Despite both lines being wrapped in try/catch, when something goes wrong in the cache it takes all of Node down in strange ways. Since #20136 most recently touched the cache, we are trying to get back to the previous state for now.

@shilman
Copy link
Member Author

shilman commented Dec 8, 2022

Possible workarounds:

  1. Run build-storybook instead to see the underlying error
  2. Run storybook --ci to possibly see the underlying error

@ndelangen
Copy link
Member

ndelangen commented Dec 8, 2022

After a lot of debugging together @shilman and I discovered that core-common cache.get seems to be at fault.
No idea what's going on, but it looks like when this fails it's fatal, and node exits immediately.

I might investigate a replacement for the current cache mechanism.

@shilman
Copy link
Member Author

shilman commented Dec 9, 2022

Ta-da!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.2 containing PR #20177 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Dec 9, 2022
Repository owner moved this from Urgent to Done in Core Team Projects Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants