nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.42k stars 3.88k forks source link

0.30.0-beta1 http2.connect doesn't "work" inside node enabled worker #6539

Closed cTn-dev closed 6 years ago

cTn-dev commented 6 years ago

NWJS Version : 0.30.0-beta1 SDK Operating System : Windows 10 x64

This is a regression (worked fine in 0.29+)

Expected behavior

Event should fire (it does fire correctly in regular context)

Actual behavior

Event never fires.

How to reproduce

const http2 = require('http2');
var connection = http2.connect('https://api.binance.com'); // returns http2session
connection.on('connect', () => {
    // this never fires, it will fire when used in non-worker context
    console.log('connected');
});
Christywl commented 6 years ago

I can't reproduce this on Linux/Windows with nwjs-sdk-v0.30.0-beta1. My steps:

  1. Start this app and open the devtools, the log 'connected' is displayed
  2. Start this app with the command line option '--enable-node-worker', open the devtools, the log 'connected' is also displayed
cTn-dev commented 6 years ago

@Christywl Console by default is always in regular context, '--enable-node-worker' doesn't change that, you have to start a worker and execute the code in its context, either by providing the code directly in the worker file or by switching to a worker context inside the console.

Here is an example file that also includes the worker.

example.zip

Christywl commented 6 years ago

Thanks for your example, I can reproduce this issue now with nwjs-sdk-v0.30.0-beta1.

rogerwang commented 6 years ago

This is fixed in git and will be available in the next nightly build.

rogerwang commented 6 years ago

https://dl.nwjs.io/live-build/nw30/03-28-2018/a3b2369-c51f71f-3997f5c-227a27b/v0.30.0-beta1/

cTn-dev commented 6 years ago

Thanks @rogerwang , i can confirm its fixed now.