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.

HTTP request callback function inside reporter not called

See original GitHub issue
  1. Newman Version (can be found via newman -v): 4.5.5
  2. OS details (type, version, and architecture): macOS
  3. Are you using Newman as a library, or via the CLI? CLI

I am trying to use the node request library from within a Newman reporter. Below is a sample code:

    newman.on('beforeDone', () => {
      console.log('before');

      var request = require('request');
      request('http://httpbin.org/get', function (error, response, body) {
        console.log('error:', error); // Print the error if one occurred
        console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
        console.log('body:', body); // Print the HTML for the Google homepage.
      });

      console.log('after');
    });

Maybe I am missing something, but the console.log statements inside the callback function are not called. Only before and after is printed.

Do you have any idea why?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
vdespacommented, Oct 17, 2019

@codenirvana I have managed to recreate this problem in a more stable environment:

https://gitlab.com/user-questions/newman-issues-2148

I have two parallel jobs, using the same code, one running a collection with tests that pass and the other one running a collection with tests that fail.

Passing output: https://gitlab.com/user-questions/newman-issues-2148/-/jobs/323512933 Failing output: https://gitlab.com/user-questions/newman-issues-2148/-/jobs/323512932

Only when the collection test pass, will the callback be executed.

0reactions
zeburekcommented, Jul 28, 2020

@codenirvana Is there any update on this issue? I’m also faced issue described in https://github.com/postmanlabs/newman/issues/2148#issuecomment-543075798

I’m writing new reporter for quite new TMS and this looks like a very unexpected behaviour. I also have lots of async request, which are correctly served when all tests are passed and not - when something is failed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP request callback not being fired - Forums
In my handlers, I have an intent (SelectGardenIntent) that obtains the user_id (needed for following HTTP requests) from the access token successfully, ...
Read more >
Node.JS Request Module Callback Not Firing - Stack Overflow
I have tried running the above code just using standard Node.JS libraries, to no avail. The callback function is never fired and the...
Read more >
Callbacks / Callables - Manual - PHP
Callbacks registered with functions such as call_user_func() and call_user_func_array() will not be called if there is an uncaught exception thrown in a ...
Read more >
5.x API - Express.js
toString() may fail in multiple ways, for example foo may not be there or may not ... If a function, the type option...
Read more >
Write HTTP functions - Documentation - Google Cloud
In Cloud Functions, you use HTTP functions when you want to invoke a function via an HTTP(S) request. To allow for HTTP semantics,...
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