coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.81k stars 356 forks source link

Multiple instances created #215

Closed dsbert closed 4 years ago

dsbert commented 6 years ago

I have a server running two different applications with node-windows. One of these is a web server and one is a file monitor. At right about the same time, both of these seem to have lost track of the running instance and I ended up with multiple instances of each application running. I had to manually stop the services and kill all remaining instances through task manager. I'm having trouble finding a root cause.

I do see the following error in the event logs at about that time (app.exe is one of the shims located in the daemon folder). I did not see this for the other application, but right after this is when I begin seeing errors indicating another instance already had the application port open.

Log Name:      Application
Source:        VsJITDebugger
Date:          7/16/2018 6:40:52 PM
Event ID:      4096
Task Category: None
Level:         Error
Keywords:      Classic
User:          SYSTEM
Computer:      -
Description:
An unhandled exception ('System.IO.IOException') occurred in app.exe [35524]. Just-In-Time debugging this exception failed with the following error: The operation attempted is not supported.

Check the documentation index for 'Just-in-time debugging, errors' for more information.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="VsJITDebugger" />
    <EventID Qualifiers="49152">4096</EventID>
    <Level>2</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2018-07-16T22:40:52.000000000Z" />
    <EventRecordID>93287</EventRecordID>
    <Channel>Application</Channel>
    <Computer>-</Computer>
    <Security UserID="S-1-5-18" />
  </System>
  <EventData>
    <Data>An unhandled exception ('System.IO.IOException') occurred in app.exe [35524]. Just-In-Time debugging this exception failed with the following error: The operation attempted is not supported.

Check the documentation index for 'Just-in-time debugging, errors' for more information.</Data>
    <Binary>21400080</Binary>
  </EventData>
</Event>
coreybutler commented 6 years ago

Is your app configured to do something on the file system, like reading/writing a file? error: The operation attempted is not supported. suggests there is an issue interacting with the file system... which is often permissions related.

dsbert commented 6 years ago

Yes it does handle files. However, I do not understand how an IO exception thrown in node could manifest as an unhandled System.IO.IOException in the shim.

coreybutler commented 4 years ago

Closing due to age, and apologies to @dsbert for being no help whatsoever. If anyone else runs into issues where there are port conflicts, use porthog to identify the service and confirm whether it is an orphan process or node-windows just trying to restart the process.