Repository navigation
remoteSettings event is not emitted on a HTTP/2 session when given a socket with some data #35981
Description
Activity
/cc @mmomtchev
await new Promise(resolve => setTimeout(resolve, 1000)); console.log(session.remoteSettings);
If we add the piece above then we'll see that it has received the settings, but didn't emit the
remoteSettingsevent.Yes, I did mention it in the comments of the PR, but the PR was already approved and it stayed like this
Everything works beside the remote settings event
Making the connection work was trivial and sending the remote settings event required moving some code around and as this was one of my first PRs in Node I didn't do itReacted by Szymon MarczakYes, I did mention it in the comments of the PR
Hmm... I think I'm blind because I cannot find it... Or was that a different PR?
Making the connection work was trivial and sending the remote settings event required moving some code around and as this was one of my first PRs in Node I didn't do it
Cool. Thanks anyway :) Greatly appreciated.
Most likely
fails which means that data is received before any listener is attached.
Seems like
should be wrapped in a
process.nextTick(() => { ... }).This proves that's right:
https://runkit.com/szmarczak/5fa47f71dbabb1001b64a492
const http2 = require('http2'); const tls = require('tls'); const options = { ALPNProtocols: ['h2'], host: 'nghttp2.org', servername: 'nghttp2.org', port: 443 }; const socket = tls.connect(options, async () => { console.log('Connected!'); await new Promise(resolve => setTimeout(resolve, 1000)); const data = socket.read(); const session = http2.connect('https://nghttp2.org', { createConnection: () => socket }); const kHandle = Object.getOwnPropertySymbols(session).find(x => x.toString() === 'Symbol(kHandle)'); process.nextTick(() => { session[kHandle].receive(data); }); session.once('remoteSettings', () => { console.log('Received remote settings!'); }); });
I'll make a PR.
@szmarczak clean my
console.logfrom the unit test while you are at italready did :)
Linux solus 5.6.19-159.current #1 SMP PREEMPT Fri Oct 16 17:49:06 UTC 2020 x86_64 GNU/LinuxWhat steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
What do you see instead?
Additional information
Related with #35678 and #35475