I noticed that my node.js application is intermittently throwing an Unhandled 'error' event when processing write requests, shortly after I configured it to run behind Nginx

Having been successfully running node.js(0.8.20 and 0.9.10) on Windows Server 2012 for weeks without any issues, I recently added Nginx(1.2.6) to the mix. However, after configuring Nginx as follows:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
worker_connections  1024;
}


http {
include       mime.types;
default_type  application/octet-stream;

sendfile        on;
keepalive_timeout  65;

upstream dem2 {
    server 127.0.0.1:8080;
}

server {
    listen 80;
    server_name dem2.cz dem2;
    access_log /nginx-1.2.6/logs/dem2.log;
    location / {
        proxy_pass http://dem2/;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_redirect off;
    }
}   

server {
    listen 80;
    server_name localhost;

    location / {
        root   html;
        index  index.html index.htm;
    }

}

}

I am now encountering a random error in my Node.js application when receiving requests:

events.js:69
    throw arguments[1]; // Unhandled 'error' event
                   ^
Error: socket hang up
    at createHangUpError (http.js:1383:15)
    at ServerResponse.OutgoingMessage._writeRaw (http.js:499:26)
    at ServerResponse.OutgoingMessage._send (http.js:466:15)
    at ServerResponse.OutgoingMessage.end (http.js:911:18)
    at SendStream.notModified (C:\dem2cz_node_app\node_modules\express\node_modules\send\lib\send.js:223:7)
    at SendStream.send (C:\dem2cz_node_app\node_modules\express\node_modules\send\lib\send.js:353:17)
    at SendStream.pipe     (C:\dem2cz_node_app\node_modules\express\node_modules\send\lib\send.js:322:10)
    at Object.oncomplete (fs.js:93:15)

Process finished with exit code 1

It seems that there might be a configuration issue with Nginx causing this error, but I am unsure of what it could be. Any advice would be greatly appreciated.

If needed, I can also share the Node.js code which is a simple 100-line Express app serving AngularJS static files with the ability to serve HTML generated in PhantomJS for bots.

Answer №1

Version 0.8.20 saw a bugfix that led to an increase in "http hang-up" errors being reported. The details can be found in the release notes. Just like @johnsmith mentioned, there is no cause for alarm, but it's important to handle error events from the http server to prevent any potential crashes.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is Implementing a Promise for Preprocessing in NodeJS Worth It?

Looking to achieve the following using NodeJS + Express: Client sends a post request with JSON document data={text: "I love Stackoverflow", shouldPreprocess: <true or false>}; Need to call an external WebSocket service for sentiment analysis on the ...

Node.js causing NPM error message to pop up consistently each time I launch the terminal

Hey there! Every time I open my terminal on my MacBook (OSX 10.15.4), I encounter this error message: /Users/anarenault/.nvm/v0.10.48/lib/node_modules/npm/bin/npm-cli.js:85 let notifier = require('update-notifier')({pkg}) ^^^^^^ ...

Steps to fix the postinstall error in Angular CLI

Can anyone lend a hand in resolving the following error? npm ERR! errno -4058 npm ERR! @angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2c4f40456c14021c021a">[email protected]</a> postinstall: `node ./bin/p ...

Is it possible to modify the destination of root requests in an express application?

Our department has been using a small Express app as a file browser for our work files. Users can easily drag and drop their files onto the network drive, which then displays the folder structure on a web directory. This allows my colleagues to view simple ...

Retrieve an array of data from Sequelize without any wrapping objects

Hello, I am facing an issue with the query from Sequelize that I have below. models.ProviderZoneCity.findAll({ attributes: ['zoneId'], raw : true, where : { status : 1 ...

Multiple instances of node.exe processes are being spawned due to the Task Runner Explorer in Visual Studio 2015

Currently, I am utilizing gulp for the development of a website project. The task runner explorer in Visual Studio 2015 is able to detect the gulp file, allowing me to execute tasks from there. However, there has been an issue where numerous node.exe proce ...

Unable to locate the specified view within AngularJS framework

<!doctype html> <html lang="en" ng-app="phonecatApp"> <head> <script src="/js/angular-1.5.2/angular.js"></script> <script src="/js/angular-1.5.2/angular-route.js"></script> <script src="/js/app.js">< ...

Utilizing AWS Websockets with lambda triggers to bypass incoming messages and instead resend the most recent message received

I am facing an issue when invoking a lambda that sends data to clients through the websocket API. Instead of sending the actual message or payload, it only sends the last received message. For example: Lambda 1 triggers Lambda 2 with the payload "test1" ...

Output a message from a callback function using Express.io in node.js

URGENT HELP NEEDED! I am currently utilizing socket.io to manage my sockets for routing purposes. The main issue I am facing is that within my regular POST callback function, I need to emit the result to a specific group. req.io.room(room).broadcast(&apo ...

Despite setting up express.static, Express.js is still unable to access static files

I attempted to access localhost:3000/index.html (where a static page is located), localhost:3000/javascripts/dio.js (where the JavaScript file is stored), and localhost:3000/images/dio1.jpg (where the images are housed). However, none of these resources ca ...

Modifying the value of a variable causes a ripple effect on the value of another variable that had been linked to it

After running the code below, I am receiving values from MongoDB in the 'docs' variable: collection.find({"Stories._id":ObjectID(storyId)}, {"Stories.$":1}, function (e, docs) { var results = docs; results[0].Stories = []; } I ...

Bespoke Socket.io NodeJS chamber

I am currently developing an application involving sockets where the requirement is to broadcast information only to individuals within a specific room. Below is a snippet of the code from my server.ts file: // Dependencies import express from 'expre ...

What are the steps to set up Node.js, npm, and socket.io and start using them?

Hello there! I'm new to the world of Node.js and I'm hoping someone can help me out. Can you provide a detailed, step-by-step guide on how to install Node.js, npm and socket.io? Thanks in advance! ...

Passport req.user data not persisting throughout consecutive requests

When using the local strategy in passport.js, I'm attempting to access req.user to get the current user ID for storing recipes in the database. However, I'm facing an issue with deserialization in the passport.js file within my app's config ...

Prevent image requests from being blocked by CORS in ExpressJS

I currently have an Express JS server up and running on domain A. It serves static files, including images and JavaScript modules. To control the access to these resources, I have implemented CORS middleware on the server which only allows requests from ap ...

Retrieve the directory path to the npm module folder that does not have a main file specified

What is the process for obtaining the path to the directory where an npm module is located? I attempted to use require.resolve, but encountered the following error: Error: Cannot find module 'bower-strapless'. (despite having already install ...

Having trouble with @aws-sdk/client-ssm (AWS SDK v3) timing out in Jest tests in Node.js

When I mock AWS SDK v3, my test cases are timing out. However, everything works fine for GetParameterCommand, but not for GetParametersCommand. Below is how my sdk file looks: const { SSMClient, GetParametersCommand } = require('@aws-sdk/client-ssm&a ...

Ways to utilize a single node_modules folder across multiple projects

Is there a simple method to centralize and share one node_modules folder among all Angular projects, thereby preventing the need to download the same dependencies each time we start a new project? If so, is this approach recommended (what are the pros and ...

Ensuring the proper export of global.d.ts in an npm package

I'm looking to release a typescript npm package with embedded types, and my file structure is set up like so dist/ [...see below] src/ global.d.ts index.ts otherfile.ts test/ examples/ To illustrate, the global.d.ts file contains typings ...

Uncovering the issue: Root admin unable to view all databases in Mongo-Express

I am facing some difficulty in setting up mongo-express with my local mongodb installation. Initially, I created an admin user using the following command: db.createUser( { user: "admin", pwd: "abc123", roles:["root"] }) In ...