question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Double callback and error on basic GET request

See original GitHub issue

Summary: When calling a GET request, I get a strange minimal error and a “double callback!” warning. Setting the exact same headers works just fine with no errors using curl or HTTPie.

Version: 1.2.0

Error:

{ [SyntaxError: Unexpected token I] response: undefined }
double callback!

Code:

        request
            .get(url)
            .set('Accept', 'application/json')
            .set('X-ApiTokenId', 'abc-123')
            .set('X-SessionId', 'def-456')
            .end((err, res) => {
                if (err) {
                    cb(err, res);
                }
                else {
                    cb(null, []);
                }
            });

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
9662commented, Aug 31, 2017

Ignore. Looking at the wrong terminal.

1reaction
9662commented, Aug 31, 2017
  "devDependencies": {
    "chai": "^4.1.1",
    "chai-as-promised": "^7.1.1",
    "chai-http": "^3.0.0",
    "chai-url": "^1.0.4",
    "mocha": "^3.5.0",
    "nyc": "^11.1.0"
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Double callback and error on basic GET request #633 - GitHub
It calls the callback and processing continues, which means that later an end listener is registered and that calls the callback again.
Read more >
Fire callback after two separate successful http requests
A simple still parallel solution would be something like: let serviceStatus = { aDone: false, bDone: false }; let getDataA = (callback: ...
Read more >
Preventing callbacks from accidentally being called twice
Another option is to keep track of whether the callback has already been called and throw an error if there's an attempt to...
Read more >
Error-First Callback in Node.js - GeeksforGeeks
Error -First Callback in Node.js is a function which either returns an error object or any successful data returned by the function.
Read more >
AWS Lambda function handler in Node.js
The callback function takes two arguments: an Error and a response. When you call it, Lambda waits for the event loop to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found