Skip to main content

socket.io

PropertyValue
Packagesocket.io
Versions Covered^4.0.0
Contract Version1.0.0
Statusproduction
Last Verified2026-02-27
Maintainercorpus-team

Installation

npm install socket.io

Covered Functions

This contract covers 2 function(s):

emit()

Emits an event to connected clients

Import:

import socket from 'socket';
socket.emit(...);

Postconditions

What happens after calling this function:

⚠️ WARNING - emit-no-error-handling

Condition: emit fails due to disconnected client or serialization error

Throws: Error may be thrown or silently fail

Required Handling:

Register 'error' event listener or wrap emit in try-catch when using acknowledgement callbacks

📖 Source


on()

Registers event handler

Import:

import socket from 'socket';
socket.on(...);

Postconditions

What happens after calling this function:

🔴 ERROR - on-handler-no-error-handling

Condition: async operation within event handler throws

Throws: Unhandled promise rejection crashes server

Required Handling:

Wrap all async operations inside event handlers with try-catch blocks

📖 Source


Example: Proper Error Handling

See Also