Skip to content

Accessing socket after HTTP2 session gets destroyed throws an error #22268

Closed
@szmarczak

Description

@szmarczak
  • Version: v10.8.0
  • Platform: Windows 10 64bit
  • Subsystem: http2

Example:

const http2 = require('http2')
const session = http2.connect(`https://google.com`);
const socket = session.socket;
const req = session.request({':path': '/', ':method': 'GET' });
req.on('close', () => {
	session.close();

	setTimeout(() => {
		socket['example'];
	}, 1000);
});

req.end();
req.resume();
internal/http2/core.js:678
        const value = socket[prop];
                            ^

TypeError: Cannot read property 'example' of undefined
    at Object.get (internal/http2/core.js:678:29)
    at Timeout.setTimeout [as _onTimeout] (/home/szymon/Desktop/bug/example.js:9:9)
    at ontimeout (timers.js:427:11)
    at tryOnTimeout (timers.js:289:5)
    at listOnTimeout (timers.js:252:5)
    at Timer.processTimers (timers.js:212:10)

ProxySocket assumes socket is available, but it's undefined after the session gets destroyed.

If this line was removed:

session[kSocket] = undefined;

it'd work I think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    http2Issues or PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions