Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:45:42+00:00 2026-06-17T12:45:42+00:00

I have this code to pull down a news feed from a third party

  • 0

I have this code to pull down a news feed from a third party website using an API. Its setup to run every 5 seconds, and pull any news transactions that may occur. The problem seems to be when there is no new transactions that occur.

By adding the process.on(‘uncaught exception’, function(error){ console.log(“hmph”) }) the cron job is able to continue 5 seconds later, so I was tempted to leave it as is; however, I added console.log(“hmph”) to the and now I’m confused.

The first time, the console will write hmph. 5 seconds later it will write
hmph
hmph

and so on. I know I must be missing something, but I’m not quite sure what it is. I’ve tried in the else statement to do request.end() but the error still fires.

Without the process.on(‘uncaught…’) the error thrown is:

events.js:71
throw arguments[1]; // Unhandled ‘error’ event
^
Error: Parse Error
at Socket.socketOnData (http.js:1367:20)
at TCP.onread (net.js:403:27)

with the proccess.on(‘uncaught…’) the console.log(error) is:

{ [Error: Parse Error] bytesParsed: 161, code: ‘HPE_INVALID_CONSTANT’ }

How do I properly handle this error?

Abbreviated code:

var job = new cronJob('*/5 * * * * *', function(){
  var request = http.get({
                            host: 'www.example.com',
                            path: '/news_feed?apicode=myapicode',
                            port: 80,
                            headers: { 'accept-encoding': 'gzip' } 
                         })

  request.on('response', function(response){
    if (response.statusCode == 200){
      // gunzip response, save response to mongodb
    } 
    else
    {
      // here is where the error is occuring
      process.on('uncaughtException',function(error){
        console.log(error);
        console.log("hmph");
    }
  });
}, null, true);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:45:43+00:00Added an answer on June 17, 2026 at 12:45 pm

    Every time you make a request, you are binding a new uncaughtException handler, so when the first request is sent, you bind the first one, and when it fails it prints an error, and then at the next request, you add another handler, and when that fails both the first and second handlers will run.

    Examining the error, and a conversation about this type of error here: https://github.com/joyent/node/issues/3354 It seems like the server you are connecting to is probably doing something weird. The easiest solution for you probably is to use the uncaughtException handler for now. That said, it is less than ideal and you should not do it as a general solution to future problems like this.

    var job = new cronJob('*/5 * * * * *', function(){
      var request = http.get({
        host: 'www.example.com',
        path: '/news_feed?apicode=myapicode',
        port: 80,
        headers: { 'accept-encoding': 'gzip' } 
      });
      request.on('response', function(response){
        if (response.statusCode == 200){
          // gunzip response, save response to mongodb
        }
      });
    }, null, true);
    
    process.on('uncaughtException',function(error){
      console.log(error);
      console.log("hmph");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using this code with great success to pull out the first
I have created this code to do a very nice, elegant pull-down sidebar navigation
I have this code: con.Open(); cmd = new MySqlCommand(String.Format(SELECT concat(name,'|',lastname) FROM {0} WHERE ID=
I have been using open_uri to pull down an ftp path as a data
I have a page where I am using jquery/ajax to pull down a chunk
I'm building an app for viewing photos I pull down from an API. Each
I have this code <div id=main style=background:#aaaaaa;float:left;height:160px;margin:5px;position:relative;display:block;width:630px;> <div id=1 class=item style=background:#ffaacc;float:left;width:200px;height:150px;margin:5px;position:absolute;left:0px;top:0px;> </div> <div id=2
I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
I have this code for changing the image of a button: - (void)mouseEntered:(NSEvent *)event
I have this code in XAML <Grid x:Name=LayoutRoot Background=Transparent> <Grid.RowDefinitions> <RowDefinition Height=Auto/> <RowDefinition Height=*/>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.