Error `TypeError: event is undefined` in manager.bundle.js after upgrade
See original GitHub issueDescribe 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:
https://github.com/storybookjs/storybook/blob/643e7eb011a880e2b4b8d82ad360752aa9461dd6/lib/channel-postmessage/src/index.ts#L176
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!
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)

Top Related StackOverflow Question
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
stringifyfunction call in @storybook/channel-postmessage’ssendmethod does not apply properly when using the vite-builder (tested against a Vite + Vue 3 + Storybook environment). It shows no problem processing thekeyandrefIdkeys. However, when processing theeventkey, it looks like it systematically catches a TypeError stating thatisObject is not a functionand returnsundefined, resulting in @julrich’s error.This happens for the following messages:
And this may be why:
shilman, if you see this, I plead not guilty Your Honor 😄
Can confirm, fixes the issue for us! Thanks a lot for the quick turnaround!