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

node:http ClientRequest invalid arguments #19209

Closed
sergeysolovev opened this issue May 21, 2023 · 9 comments · Fixed by #19211
Closed

node:http ClientRequest invalid arguments #19209

sergeysolovev opened this issue May 21, 2023 · 9 comments · Fixed by #19211
Labels
bug Something isn't working correctly node compat

Comments

@sergeysolovev
Copy link

sergeysolovev commented May 21, 2023

Failes on Deno 1.33.4 and works without issues on Deno 1.33.3. Repro script (feel free to use your own telegram bot token):

import TelegramBot from 'npm:node-telegram-bot-api@0.61.0';

const TOKEN = '<REDACTED>';
new TelegramBot(TOKEN, { polling: true });

Stack:

error: [polling_error] %j RequestError: TypeError: Error parsing args at position 2: serde_v8 error: invalid type; expected: string, got: Number
    at new RequestError (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/request-promise-core/1.1.4/lib/errors.js:14:15)
    at Request.plumbing.callback (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/request-promise-core/1.1.4/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/request-promise-core/1.1.4/lib/plumbing.js:46:31)
    at self.callback (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/request/2.88.2/request.js:185:22)
    at Request.emit (ext:deno_node/_stream.mjs:1852:9)
    at Request.start (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/request/2.88.2/request.js:753:10)
    at Request.write (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/request/2.88.2/request.js:1491:10)
    at end (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/request/2.88.2/request.js:549:18)
    at Timeout._onTimeout (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/request/2.88.2/request.js:578:7)
    at cb (ext:deno_node/internal/timers.mjs:37:46)
    at Object.action (ext:deno_web/02_timers.js:149:11)
    at handleTimerMacrotask (ext:deno_web/02_timers.js:66:10)
    at eventLoopTick (ext:core/01_core.js:187:21) {
  code: "EFATAL"
}
@egous-bunnings
Copy link

egous-bunnings commented May 22, 2023

I believe I have had a related issue, I am using a library called graphql-request to use GraphQL APIs from Github.
After a recent Deno update the data for responses seems to be returned inside of an "error" property.
When I rolled back to an older version of Deno my issue was resolved.
1.33.3 worked
1.33.4 did not

image

@bartlomieju
Copy link
Member

@egous-bunnings thanks for the report, I believe it's a separate issue to the problem at hand. Could you open a new issue? Some steps to reproduce the problem would be very helpful for us to track down the problem.

@bartlomieju bartlomieju added bug Something isn't working correctly node compat labels May 22, 2023
@bartlomieju bartlomieju changed the title Deno request issue node:http ClientRequest invalid arguments May 22, 2023
@egous-bunnings
Copy link

@bartlomieju the issue I had has some sensitive data in it which I cannot share;
I dont have simple recreation steps either that can I describe just with instructions as I will need to rebuild an entire app to demonstrate.
FWIW this issue described before on a different github explains exactly what I experienced.
jasonkuhrt/graffle#140

If I had to make an educated guess I am thinking that

  1. there was a change in the behavior of header handling in a recent update
  2. Either the accept OR content-type header that gets sent with outbound requests are somehow not sent or changed to something else.
  3. I see an error back from the responding API because the library I use doesnt know how to parse a response type that isnt application/graphql+json; charset=UTF-8 or application/json

@sergeysolovev
Copy link
Author

sergeysolovev commented May 28, 2023

Hello, not sure if it’s fixed, it still reproduces (Deno 1.34) using the code I posted in the first message, but with different error this time:

error: [polling_error] %j Error: EPARSE: Error parsing response: <html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.18.0</center>
</body>
</html>

    at file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/node-telegram-bot-api/0.61.0/src/telegram.js:292:17
    at tryCatcher (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/bluebird/3.7.2/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/bluebird/3.7.2/js/release/promise.js:547:31)
    at Promise._settlePromise (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/bluebird/3.7.2/js/release/promise.js:604:18)
    at Promise._settlePromise0 (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/bluebird/3.7.2/js/release/promise.js:649:10)
    at Promise._settlePromises (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/bluebird/3.7.2/js/release/promise.js:729:18)
    at _drainQueueStep (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/bluebird/3.7.2/js/release/async.js:93:12)
    at _drainQueue (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/bluebird/3.7.2/js/release/async.js:86:9)
    at Async._drainQueues (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/bluebird/3.7.2/js/release/async.js:102:5)
    at Async.drainQueues (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/bluebird/3.7.2/js/release/async.js:15:14)
    at Object.action (ext:deno_web/02_timers.js:155:11)
    at handleTimerMacrotask (ext:deno_web/02_timers.js:69:10)
    at eventLoopTick (ext:core/01_core.js:188:21) {
  code: "EPARSE",

@bartlomieju bartlomieju reopened this May 28, 2023
@bartlomieju
Copy link
Member

This problem is really strange @sergeysolovev. I added an HTTPS proxy to inspect the requests going out and once I did that (export HTTPS_PROXY=192.168.1.11:9090 deno run -A --unsafely-ignore-certificate-errors repro.js the program appears to work fine (ie. the HTTP 400 errors are no longer appearing).

Is there a way to verify that the program is indeed working correctly at this point?

@levex
Copy link
Contributor

levex commented May 29, 2023

I could reproduce the 400 Bad Request issues, but I think it may be related to Telegram's API as I managed to MITM and intercepted this response:

{
  "ok": false,
  "error_code": 409,
  "description": "Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"
}

@sergeysolovev
Copy link
Author

@bartlomieju

The code above is the minimalistic version of the quickstart from https://github.com/yagop/node-telegram-bot-api
It works fine on Deno 1.33.3 (I just downgrade it) but fails on Deno 1.33.4 and Deno 1.34.

@levex This might be caused by a few of us trying to start the bot with same hard-coded token in polling mode (the default mode). To avoid this behavior it is better to create a separate dedicated bot token (it’s really quick to do in telegram).

@sergeysolovev
Copy link
Author

@bartlomieju I bumped to deno 1.34.3 and it doesnt’t reproduce anymore. I suggest to close this.

@bartlomieju
Copy link
Member

Thanks!

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

Successfully merging a pull request may close this issue.

4 participants