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

[Bug] Error Using ts-sdk for Network Requests in Deno and Bun #592

Open
WGB5445 opened this issue Nov 25, 2024 · 1 comment
Open

[Bug] Error Using ts-sdk for Network Requests in Deno and Bun #592

WGB5445 opened this issue Nov 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@WGB5445
Copy link
Contributor

WGB5445 commented Nov 25, 2024

🐛 Bug Description

When using Deno and Bun, the error occurs because the client library depends on "got" and uses HTTP2 for requests.

You can reproduce the issue with these two repos.

error: Uncaught (in promise) RequestError
    at ClientRequest.<anonymous> (file:///Users/logan/Library/Caches/deno/npm/registry.npmjs.org/got/11.8.6/dist/source/core/index.js:970:111)
    at Object.onceWrapper (ext:deno_node/_events.mjs:518:26)
    at ClientRequest.emit (ext:deno_node/_events.mjs:405:35)
    at ClientRequest.origin.emit (file:///Users/logan/Library/Caches/deno/npm/registry.npmjs.org/@szmarczak/http-timer/4.0.6/dist/source/index.js:43:20)
    at ClientRequest.flushHeaders (file:///Users/logan/Library/Caches/deno/npm/registry.npmjs.org/http2-wrapper/1.0.3/source/client-request.js:363:10)
    at Object.runMicrotasks (ext:core/01_core.js:683:26)
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:59:10)
    at runNextTicks (ext:deno_node/_next_tick.ts:76:3)
    at eventLoopTick (ext:core/01_core.js:182:21)

or

346 |                                           ...options
347 |                                   });
348 |                                   session[kCurrentStreamsCount] = 0;
349 |                                   session[kGracefullyClosing] = false;
350 | 
351 |                                   const isFree = () => session[kCurrentStreamsCount] < session.remoteSettings.maxConcurrentStreams;
                                                                        ^
TypeError: null is not an object (evaluating 'session.remoteSettings.maxConcurrentStreams')
      at isFree (/Users/logan/code/temp/test_aptos_error/bun_test/node_modules/http2-wrapper/source/agent.js:351:67)
      at /Users/logan/code/temp/test_aptos_error/bun_test/node_modules/http2-wrapper/source/agent.js:449:12
      at emit (node:events:183:48)
      at #onConnect (node:http2:730:13)
      at onConnect (node:http2:867:23)
      at emit (node:events:183:48)
      at handshake (node:net:159:14)
965 |             var _a;
966 |             // Force clean-up, because some packages (e.g. nock) don't do this.
967 |             request.destroy();
968 |             // Node.js <= 12.18.2 mistakenly emits the response `end` first.
969 |             (_a = request.res) === null || _a === void 0 ? void 0 : _a.removeAllListeners('end');
970 |             error = error instanceof timed_out_1.TimeoutError ? new TimeoutError(error, this.timings, this) : new RequestError(error.message, error, this);
                                                                                                                    ^
RequestError: ERR_HTTP2_ERROR: h2 is not supported
 code: "ERR_HTTP2_ERROR"

      at /Users/logan/code/temp/test_aptos_error/bun_test/node_modules/got/dist/source/core/index.js:970:111
      at onceWrapper (native:1:1)
      at emitError (native:1:1)
      at /Users/logan/code/temp/test_aptos_error/bun_test/node_modules/http2-wrapper/source/client-request.js:363:10
      at processTicksAndRejections (native:1:1)
      at #onConnect (node:http2:730:13)
      at onConnect (node:http2:867:23)
      at emit (node:events:183:48)
      at handshake (node:net:159:14)

Bun v1.1.30 (macOS arm64)

How to reproduce

https://github.com/WGB5445/test_deno_aptos_ts_sdk

https://github.com/WGB5445/test_bun_aptos_ts_sdk

System information

System details:

  • Typescript SDK Version: latest
  • Platform: deno / bun
@WGB5445 WGB5445 added the bug Something isn't working label Nov 25, 2024
@GhostWalker562
Copy link
Contributor

GhostWalker562 commented Nov 26, 2024

For Bun, they don't support the allowHttp1 flag for the HTTP2 module which got relies on.
For Deno, the issue is likely with the runtime, believe it might have to do the the "stream" module.

These issues should be brought up to the runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants