-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Fix(react-native) add missing ws
dependency
#1174
Conversation
Fixes this error on startup: ``` this.wsServer = _ws2.default.Server({ server: this.httpServer }); ^ TypeError: Class constructor WebSocketServer cannot be invoked without 'new' at new Server (.../node_modules/@storybook/react-native/dist/server/index.js:48:34) ```
Codecov Report
@@ Coverage Diff @@
## master #1174 +/- ##
========================================
Coverage 13.31% 13.31%
========================================
Files 199 199
Lines 4588 4588
Branches 724 522 -202
========================================
Hits 611 611
- Misses 3349 3515 +166
+ Partials 628 462 -166
Continue to review full report at Codecov.
|
Thanks, I'll ask another react-native user to give this a test. on positive I'll merge it! Can you explain to error message / bug a bit more? So it can be tested better and have a good changelog later on. |
Sure? I just ran |
Howdy @shilman – how would you like me to test this? There don't appear to be any tests setup for this kind of thing as far as I can tell? |
Hi @joeybaker FYI I dismissed @ndelangen 's review because he didn't test it, not because you didn't provide tests. We were discussing this in Slack and are a little confused about the change, since we've all been using storybook/react-native without problems. I'll work with you to get this in, or at least figure out what's going on. |
hmmm… I'm not quite sure how I'm special then :). I'm happy to hope into a slack/IRC if you want. FWIW, the |
@joeybaker Sure, jump into slack, or we can discuss here. Either way! https://storybooks-slackin.herokuapp.com/ If you can provide a broken repro, I'd love to look at it. I'll also provide you a working repro, and you can try it on your machine. |
This fix works for me locally as well. |
@joeybaker don't doubt your fix, just trying to understand why it's working for most people. here's the simple repro that works on my machine: shell1: yarn create react-native-app rnapp
cd rnapp
getstorybook
yarn storybook shell2:
If I understand your fix properly this should break, but it doesn't. Any ideas? |
Hmm… a few thoughts:
|
@joeybaker mind sharing an analogous repro? I'd love to figure this out |
This is a little bit of a tricky one, the new keyword was introduced in v2.0.0. If you notice,
@joeybaker - does your project define it's own Next stepsWe should add Could someone double check my thinking here: is it okay if you specify a dependency at a version that is different from another dependency who has the same module as their dependency? (that's a mouthful) For example:
|
I think this is okay? It's marked as "extraneous", but I think it would still use it? Package A (test-a) Package B (test-b)
yields
|
@ajwhite Good call! We specify
Resulting in: cat node_modules/ws/package.json | json version
→ 3.0.0 So, if The answer to your second question is that the two I completely agree that |
😃 thanks for clearing this up! I felt like this was the answer, but wanted to be 100%. So it sounds like we can add the appropriate version as a dependency and we should be good here. I think we can all agree being on the later version is the proper path forward? Otherwise we can specify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the current form will lead to a breaking change, dropping in this review to make sure we add the ws
dependency to @storybook/react-native
before merging
It's a dependency already!
new
ws
dependency
@ajwhite I added |
Thanks @joeybaker, if anyone can give this a test that would be great. Otherwise I can try to follow up tomorrow 📆 |
dependency added, haven't been able to test yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joeybaker @ajwhite tested on my local machine with CRNA. Before this PR:
[email protected] /Users/shilman/projects/storybook/new/rnapp
├── UNMET PEER DEPENDENCY [email protected]
└─┬ UNMET PEER DEPENDENCY [email protected]
├─┬ [email protected]
│ └── [email protected]
└── [email protected]
After this PR:
[email protected] /Users/shilman/projects/storybook/new/rnapp
├─┬ @storybook/[email protected] invalid
│ ├── UNMET PEER DEPENDENCY [email protected] extraneous
│ └── [email protected] extraneous
├── UNMET PEER DEPENDENCY [email protected]
└─┬ UNMET PEER DEPENDENCY [email protected]
├─┬ [email protected]
│ └── [email protected]
└── [email protected]
And it's working for me. Merging. Thanks for the fix @joeybaker and @ajwhite !
Issue
ws
was a dependency, but wasn't specified inpackage.json
. We got away with this b/cws
is a dependency ofreact-native
, but that causes a problem because the version ofws
used bystorybook
is non-deterministic. This can cause the following error on startup:What I did
Added
new
, and addedws
topackage.json
How to test
Just run
storybook start
. It now works. Before, it would crash.