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

Error TypeError: event is undefined in manager.bundle.js after upgrade #14910

Closed
julrich opened this issue May 13, 2021 · 7 comments
Closed

Error TypeError: event is undefined in manager.bundle.js after upgrade #14910

julrich opened this issue May 13, 2021 · 7 comments

Comments

@julrich
Copy link

julrich commented May 13, 2021

Describe the bug
After updating the vite builder (https://github.com/eirslett/storybook-builder-vite) to 0.0.6, and updating Storybook to 6.3.0-alpha.25, we are greeted by the following error in the browser console:

TypeError: event is undefined

This is the line that triggers the error, because event is undefined:

const eventString = Object.values(EVENTS).includes(event.type)

And the event in question is:

"message":{
   "target":"Window",
   "isTrusted":true,
   "data":"{\"key\":\"storybook-channel\",\"refId\":\"_undefined_\"}",
   "origin":"http://localhost:3000",
   "lastEventId":"",
   "source":"Window",
   "ports":"Restricted",
   "srcElement":"Window",
   "currentTarget":"Window",
   "eventPhase":2,
   "…"
}

To Reproduce
Unfortunately this isn't really easy for me to extract from our use-case. If it turns out to be hard to reproduce, I'd try my hand on a smaller repro.

System

Environment Info:

  System:
    OS: Linux 5.11 Arch Linux
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 12.22.1 - ~/.nvm/versions/node/v12.22.1/bin/node
    Yarn: 1.22.10 - /usr/bin/yarn
    npm: 6.14.12 - ~/.nvm/versions/node/v12.22.1/bin/npm
  Browsers:
    Firefox: 87.0

Additional context
Not entirely sure if this error originates in Storybook, the vite builder or the unique combination of both!

Let me know if I can help further!

@Dschungelabenteuer
Copy link
Member

Dschungelabenteuer commented May 14, 2021

I hope I'm not completely mistaken but from what I've seen while taking a look at this issue, it seems like telejson's stringify function call in @storybook/channel-postmessage's send method does not apply properly when using the vite-builder (tested against a Vite + Vue 3 + Storybook environment). It shows no problem processing the key and refId keys. However, when processing the event key, it looks like it systematically catches a TypeError stating that isObject is not a function and returns undefined, resulting in @julrich's error.

This happens for the following messages:

  • currentStoryWasSet
  • docsRendered
  • storySpecified
  • setStories

And this may be why:

issue-14910

shilman, if you see this, I plead not guilty Your Honor 😄

@shilman
Copy link
Member

shilman commented May 15, 2021

@Dschungelabenteuer Thanks so much for tracking this down! The only thing you're guilty of is being amazing!!! ❤️

@shilman
Copy link
Member

shilman commented May 15, 2021

@ndelangen @eirslett any idea what could be going on here?

@julrich
Copy link
Author

julrich commented May 15, 2021

And let me know if I can help some way!

@ndelangen
Copy link
Member

We should update storybook to use the new version of telejson

@shilman
Copy link
Member

shilman commented May 19, 2021

Shiver me timbers!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.3.0-alpha.34 containing PR #14983 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 May 19, 2021
@julrich
Copy link
Author

julrich commented May 19, 2021

Can confirm, fixes the issue for us! Thanks a lot for the quick turnaround!

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

4 participants