Skip to content

http2: check if callback is valid before closing the request? #18855

Closed
@trivikr

Description

@trivikr
  • Version: master
  • Platform: N/A
  • Subsystem: http2

I came across this issue while writing unit tests for req.close(code) in PR #18854
The function currently checks if callback is valid after performing close operation

if (callback !== undefined) {
if (typeof callback !== 'function')
throw new errors.TypeError('ERR_INVALID_CALLBACK');
this.once('close', callback);
}

In other functions (for example ping(), settings() etc) the validity for callback is checked before function performs it's operation:

if (typeof callback !== 'function')
throw new errors.TypeError('ERR_INVALID_CALLBACK');

if (callback && typeof callback !== 'function')
throw new errors.TypeError('ERR_INVALID_CALLBACK');

Is there a reason why req.close(code) performs close operation even if callback is invalid?

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