Registry / messaging / sc-publish-out-queue

sc-publish-out-queue

JSON →
library0.2.2jsnpmunverified

SocketCluster middleware that queues outgoing publish messages and emits them in batches to avoid overwhelming the socket. Current stable version 0.2.2 (released November 2017). Provides configurable timeout, batch size, and debug mode. Differs from plain socket.publish by batching messages with timeout control, reducing network churn in high-throughput SocketCluster applications. No updates since 2017; works with SocketCluster v5/v6, but not actively maintained.

npm install sc-publish-out-queue
INSTALL
IMPORT
SIG · SC-PUBLISH-OUT-QUE
S
sc-publish-out-queue
messagingjavascriptv0.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import attach from 'sc-publish-out-queue'
✗ const { attach } = require('sc-publish-out-queue')
Package exports a single function; named import fails because it's not a named export. Use default import for ESM or require() directly for CJS.
require
✓ const scPublishOutHandler = require('sc-publish-out-queue')
✗ import scPublishOutHandler from 'sc-publish-out-queue'
Package declares no module field; default import works in bundlers that handle CJS interop, but many TS configs require 'esModuleInterop'.
attach
✓ const { attach } = require('sc-publish-out-queue')
✗ const attach = require('sc-publish-out-queue').attach
attach is the only method; destructuring from require() is sugar. Both work, but destructuring is cleaner.

Shows how to attach the publish queue middleware to a SocketCluster worker with custom options.

const scPublishOutHandler = require('sc-publish-out-queue'); // Inside SocketCluster worker scPublishOutHandler.attach(worker, { debug: false, // log queue actions timeout: 10, // ms between batches (default 10) numOfMessagesPerPass: 100 // messages per batch (default 100) }); // Now socket.publish('channel', data) will be queued and emitted in batches
Debug
Known issues
gotchaSocket not connected check added in v0.2.2; earlier versions might emit to disconnected sockets causing errors.
fix
Upgrade to v0.2.2 or later.
affects: <0.2.2
deprecatedPackage not updated since 2017; may be incompatible with SocketCluster v7+ (which moved to TypeScript and changed APIs).
fix
Consider alternative: implement custom batching with sc-channel or raw socket events.
affects: >=0.0.0
gotchaRequires worker context; attaching in a broker or client context silently fails.
fix
Only use inside SocketCluster worker initialization.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: scPublishOutHandler.attach is not a function
Wrong import method: destructured named export instead of default import or full require.
fix
Use: const scPublishOutHandler = require('sc-publish-out-queue'); scPublishOutHandler.attach(worker, options);
Error: Cannot find module 'sc-publish-out-queue'
Package not installed or missing from node_modules.
fix
Run: npm install sc-publish-out-queue --save
ReferenceError: worker is not defined
attach called outside SocketCluster worker context.
fix
Use only inside worker file (e.g., worker.js) where 'worker' is passed to the function.
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies
sc-publish-out-queuerequiredRuntime dependency to attach queue middleware to worker
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
2
Resources
sc-publish-out-queue — npm install sc-publish-out-queue · libregistry