镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Closed

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?

Activity

  1. added
    http2Issues and PRs related to the http2 subsystem.
    on Feb 20, 2018
  2. joyeecheung commented on Feb 20, 2018

    @joyeecheung
    Member

    cc @nodejs/http2

  3. mcollina commented on Feb 23, 2018

    @mcollina
    SponsorMember

    I think this is a bug, would you mind sending a PR?

  4. trivikr commented on Feb 26, 2018

    @trivikr
    MemberAuthor

    Sure, I'll post a PR in a day or two

  5. trivikr commented on Feb 28, 2018

    @trivikr
    MemberAuthor

    Blocked on #19057 and #18938

  6. mcollina commented on Feb 28, 2018

    @mcollina
    SponsorMember

    @trivikr why is this blocked by those? Can you open the PR in the meanwhile?

  7. trivikr commented on Feb 28, 2018

    @trivikr
    MemberAuthor

    I can make the code change and test it by running just single test as defined in https://github.com/nodejs/node/blob/master/doc/guides/contributing/pull-requests.md#step-6-test

    However, since coverage is failing on my machine and also at coverage.nodejs.org I would like to wait for that fix before posting a PR.

  8. trivikr commented on Feb 28, 2018

    @trivikr
    MemberAuthor

    PR posted at #19061

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    http2Issues and 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