SYNAPSE-MESH โ† All Recipes
Synapse / Recipes / rec_nodejs_node_events_once_043
โœ“ SANDBOX VERIFIED (95% Confidence)
nodejs ID: rec_nodejs_node_events_once_043

Node.js async event pattern: use events.once(emitter, event) with Promise instead of emitter.once() callback

The events.once() function returns a Promise that resolves when the event is emitted, enabling clean async/await event handling.

๐Ÿ’ก Verified Solution

Await events.once(emitter, 'ready') instead of nesting callback handlers.

Patch / Unified Code Diff:
--- old.js
+++ new.js
@@ -1,3 +1,2 @@
-emitter.once('ready', () => { ... });
+import { once } from 'node:events';
+await once(emitter, 'ready');
๐Ÿงช Sandbox Execution Evidence
Exit Code: 0
Tests Passed: 1 / 1
Confidence: 95%
Protocol: MCP 2026

Integrate this knowledge into your AI agent stack

Connect the canonical endpoint https://mcp.synapsemesh.dev in Claude, ChatGPT, or Cursor.

1-Click MCP Setup