Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running tests on node 20 #15

Closed
thomas9911 opened this issue Oct 19, 2023 · 4 comments · Fixed by #16
Closed

Error when running tests on node 20 #15

thomas9911 opened this issue Oct 19, 2023 · 4 comments · Fixed by #16
Labels
Type: Bug Bug or Bug fixes

Comments

@thomas9911
Copy link

thomas9911 commented Oct 19, 2023

Im running the tests and I get an internal error:

Node version:

$ node --version
v20.8.0

OS version:

$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"

Reproduce:

yarn test

Output:

  1) request-filtering-agent
       should not request because the dns-lookuped address is private:
     Uncaught Error: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

      at new NodeError (node:internal/errors:406:5)
      at assert (node:internal/assert:14:11)
      at internalConnect (node:net:1037:3)
      at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
      at GetAddrInfoReqWrap.emitLookup [as callback] (node:net:1481:9)
      at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:130:8)

  2) request-filtering-agent
       "after each" hook in "request-filtering-agent":
     Error: done() called multiple times in hook <request-filtering-agent "after each" hook in "request-filtering-agent"> of file /data/Code/request-filtering-agent/test/request-filtering-agent.test.ts; in addition, done() received error: Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

      at process.emit (node:events:526:35)
      at process.emit (node:domain:488:12)
      at process.emit (node_modules/source-map-support/source-map-support.js:495:21)
      at process._fatalException (node:internal/process/execution:159:25)

  3) request-filtering-agent
       should not request because it is not resolve - timeout:
     Uncaught Error: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

      at new NodeError (node:internal/errors:406:5)
      at assert (node:internal/assert:14:11)
      at internalConnect (node:net:1037:3)
      at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
      at GetAddrInfoReqWrap.emitLookup [as callback] (node:net:1481:9)
      at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:130:8)

  4) request-filtering-agent
       should request public ip address:
     Uncaught Error: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

      at new NodeError (node:internal/errors:406:5)
      at assert (node:internal/assert:14:11)
      at internalConnect (node:net:1037:3)
      at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
      at GetAddrInfoReqWrap.emitLookup [as callback] (node:net:1481:9)
      at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:130:8)



/data/Code/request-filtering-agent/node_modules/mocha/lib/runner.js:962
    throw err;
    ^

Error: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

    at new NodeError (node:internal/errors:406:5)
    at assert (node:internal/assert:14:11)
    at internalConnect (node:net:1037:3)
    at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
    at GetAddrInfoReqWrap.emitLookup [as callback] (node:net:1481:9)
    at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:130:8) {
  code: 'ERR_INTERNAL_ASSERTION'
}
@azu azu added the Type: Bug Bug or Bug fixes label Oct 19, 2023
@azu
Copy link
Owner

azu commented Oct 19, 2023

Thanks for report.

Probably, agent.createConnection = ... override cause this issue.

agent.createConnection = (options: TcpNetConnectOpts, connectionListener?: (error?: Error) => void) => {

We need to find workaround this.

@azu azu mentioned this issue Oct 20, 2023
2 tasks
@azu
Copy link
Owner

azu commented Oct 20, 2023

It seems to work in Node.js 20 by overriding it with a subclass of http.Agent.
But, It may includes breaking change. We need to update it as major.(We can not test on Node.js 12, 14).

@thomas9911
Copy link
Author

Very nice, thank you for the super fast response

@azu azu closed this as completed in #16 Oct 21, 2023
azu added a commit that referenced this issue Oct 21, 2023
## Bug Fixes

- Support Node.js 20 - #15 

v2.0.0 fixes following error on Node.js 20+

```
Uncaught Error: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
```

## BREAKING CHANGE

| Version | Node.js 12 | Node.js 14 | Node.js 16 | Node.js 18 | Node.js 20  |
| :------ | :--------- | :--------- | :--------- | :--------- | :---------- |
| v1.x.x  | Support    | Support    | Support    | Support    | Not Support |
| v2.0.0  | No Support | No Support | No Support | Support    | Support     |

- Drop Node.js 12, 14, 16
- Remove `applyRequestFilter(agent)` function
  - It is incompatible way for Node.js 20+
  - So, It is just dropped
- Remove `stopPortScanningByUrlRedirection` option
  - We already block the redirect attack pattern
  - It is duplicated option and just drop `stopPortScanningByUrlRedirection`
  - https://github.com/azu/request-filtering-agent/blob/a0a348ead386728aaf3e21cddbee3fb077c3d3bf/test/request-filtering-agent.test.ts#L195
@azu
Copy link
Owner

azu commented Oct 21, 2023

I've released v2.0.0
https://github.com/azu/request-filtering-agent/releases/tag/v2.0.0
It will work on Node.js 20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug or Bug fixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants