nanoexpress / legacy

[Deprecated] Nano-framework for Node.js. Use PRO version
https://nanoexpress.js.org
Apache License 2.0
107 stars 13 forks source link

Websocket App publish crashes #99

Closed joeyshipley closed 4 years ago

joeyshipley commented 4 years ago

When attempting to call app.publish('broadcast', 'test message'); after the app.ws is setup causes the application to silently crash/die.

joeyshipley commented 4 years ago

Exploring this a bit, I found that updating nanoexpress.js in the const _app creation that updating the function setting seems to not crash this.

_app.publish = (channel, message) => app.publish(channel, message);

I am still having issues with my channels/subscriptions, so I'll keep poking at it before trying a PR out.

joeyshipley commented 4 years ago

After updating my local version to use the passthrough for the publish method, I was able to get it working without issue. I can provide code/examples if needed.

If it helps, here's a PR > https://github.com/nanoexpress/nanoexpress/pull/100.

dalisoft commented 4 years ago

If possible, please, add example.

Thanks

joeyshipley commented 4 years ago

Happy to. Thanks for addressing it so quickly. :)

https://github.com/joeyshipley/nanoexpress-publish

I have a local project that has a front end listening to the channel and it receives messages after the change. It's much larger though, not sure how to easily share end results past the server staying alive.

dalisoft commented 4 years ago

Issue not fixed, i got error

nanoexpress on  master [⇣] is 📦 v2.0.2 via ⬢ v13.14.0 
❯ NODE_ENV=development node examples/pub-sub.js 
  [nanoexpress:error] `cookie` was not found in your dependencies list, please install yourself for this feature working properly +0ms
  [nanoexpress:error] `cookie` was not found in your dependencies list, please install yourself for this feature working properly +2ms
  [nanoexpress:error] `fast-json-stringify` was not found in your dependencies list, please install yourself for this feature working properly +0ms
  [nanoexpress:log] [Server]: started successfully at [localhost:4000] in [7ms] +0ms
Sending publish/broadcast message to channel > my-channel
fish: 'NODE_ENV=development node examp…' terminated by signal SIGSEGV (Address boundary error)
nanoexpress on  master [!?] is 📦 v2.0.3 via ⬢ v13.14.0 
❯ bash

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
bash-3.2$ node -v
v13.14.0
bash-3.2$ NODE_ENV=development node examples/pub-sub.js 
  [nanoexpress:error] `cookie` was not found in your dependencies list, please install yourself for this feature working properly +0ms
  [nanoexpress:error] `cookie` was not found in your dependencies list, please install yourself for this feature working properly +2ms
  [nanoexpress:error] `fast-json-stringify` was not found in your dependencies list, please install yourself for this feature working properly +0ms
  [nanoexpress:log] [Server]: started successfully at [localhost:4000] in [5ms] +0ms
Sending publish/broadcast message to channel > my-channel
Segmentation fault: 11
bash-3.2$ NODE_ENV=development node --trace-uncaught examples/pub-sub.js 
  [nanoexpress:error] `cookie` was not found in your dependencies list, please install yourself for this feature working properly +0ms
  [nanoexpress:error] `cookie` was not found in your dependencies list, please install yourself for this feature working properly +2ms
  [nanoexpress:error] `fast-json-stringify` was not found in your dependencies list, please install yourself for this feature working properly +0ms
  [nanoexpress:log] [Server]: started successfully at [localhost:4000] in [4ms] +0ms
Sending publish/broadcast message to channel > my-channel
Segmentation fault: 11
bash-3.2$ npm outdated
^C
bash-3.2$ exit
exit
nanoexpress on  master [!?] is 📦 v2.0.3 via ⬢ v13.14.0 took 1m25s 
joeyshipley commented 4 years ago

Hrm, I'm still on LTS. I'll pull that node version and see on my end. -- update 13.14.0 worked for me also. I'm going to poke around and see if I can't make it fail again locally.

joeyshipley commented 4 years ago

I updated example repo to specifically point to the patch, I forgot to do that earlier. I'll keep poking around, but if you could try that again it would be helpful.

joeyshipley commented 4 years ago

Sorry, I'm learning some of this. How did you pull down v2.0.3?

dalisoft commented 4 years ago

It’s locally, just increased patch number

dalisoft commented 4 years ago

LTS maintenance mode comes later as currently I don’t have enough time to migrate, move to separate branch

dalisoft commented 4 years ago

I catch another bug while testing recently, so much bugs and so less time

joeyshipley commented 4 years ago

Was thinking it might be a build/compile issue, but building from the fix repo keeps the code inline and worked for me again. Going to think about this and see if I can come up with a different direction to reproduce locally.

Do you have a different example, I can try that also if you do.

dalisoft commented 4 years ago

Please look at new branch docs/example-pub-sub, error while running as described here.

Can be run with this command NODE_ENV=development node --trace-uncaught examples/pub-sub.js

joeyshipley commented 4 years ago

Oh, good catch. I wouldn't have thought to throttle the memory and test it. At any rate, thanks for work on all of this.

dalisoft commented 4 years ago

Thank you for bug-report. Of course, i didn't throttled memory, MS VSCode and Apple AppStore did it for me 😆