{"id":27670,"library":"cryo-server","title":"Cryo-Server","description":"Cryo-Server is a lightweight WebSocket server framework for Node.js that handles client authentication, session lifecycle management, and data framing. Current stable version is 2.9.4. Part of the Cryo ecosystem with client implementations for TypeScript/JavaScript (Node.js and browsers) and C# (.NET). Key differentiators: built-in backpressure support with configurable drop policies, SSL/TLS support, and an extension interface for building RPC or other protocols on top. Released on npm, with infrequent updates.","status":"active","version":"2.9.4","language":"javascript","source_language":"en","source_url":"https://github.com/Ranchonyx/Cryo-Server","tags":["javascript"],"install":[{"cmd":"npm install cryo-server","lang":"bash","label":"npm"},{"cmd":"yarn add cryo-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add cryo-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"WebSocket library used under the hood for actual WebSocket connections","package":"ws","optional":true},{"reason":"Used for Buffer manipulation, but Node.js built-in; not a real dependency","package":"buffer","optional":true}],"imports":[{"note":"cryo is a named export, not default. Package is ESM-only since v2.","wrong":"const cryo = require('cryo-server')","symbol":"cryo","correct":"import { cryo } from 'cryo-server'"},{"note":"Type-only import for TypeScript users. ITokenValidator is a TypeScript interface, not a value.","wrong":"import { ITokenValidator } from 'cryo-server'","symbol":"ITokenValidator","correct":"import type { ITokenValidator } from 'cryo-server'"},{"note":"Type-only import for TypeScript users.","wrong":"import { ICryoWebsocketServerOptions } from 'cryo-server'","symbol":"ICryoWebsocketServerOptions","correct":"import type { ICryoWebsocketServerOptions } from 'cryo-server'"}],"quickstart":{"code":"import { cryo } from 'cryo-server';\n\nconst tokenValidator = {\n  validate: async (token: string): Promise<boolean> => {\n    // Simple example: accept tokens that are not empty\n    return token.length > 0;\n  }\n};\n\nconst options = {\n  port: 8080,\n  keepAliveIntervalMs: 15000,\n  backpressure: {\n    highWaterMark: 16 * 1024 * 1024,\n    lowWaterMark: 1024 * 1024,\n    maxQueuedBytes: 8 * 1024 * 1024,\n    maxQueueCount: 1024,\n    dropPolicy: \"drop-oldest\"\n  }\n};\n\nconst server = cryo(tokenValidator, options);\n\nserver.on('session:open', (session) => {\n  console.log('Session opened:', session.id);\n  session.send('Welcome!');\n});\n\nserver.on('session:message', (session, data) => {\n  console.log('Received:', data);\n  session.send('Echo: ' + data);\n});\n\nserver.on('session:close', (session) => {\n  console.log('Session closed:', session.id);\n});","lang":"typescript","description":"Initializes a Cryo server with token validation, event listeners for session lifecycle, and backpressure configuration."},"warnings":[{"fix":"Use import { ... } from 'cryo-server' and ensure package.json includes \"type\": \"module\".","message":"In v2.0.0, the package switched to ESM-only. Using require() throws an error.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Pass port inside the options object: cryo(validator, { port: 8080 }) instead of cryo(port, validator).","message":"In v2.0.0, the cryo function signature changed: the port option moved from a separate parameter to inside the options object.","severity":"breaking","affected_versions":">=2.0.0 <2.0.0?"},{"fix":"Explicitly configure backpressure options based on your expected load.","message":"If no backpressure configuration is provided, default values are used which may not suit high-load scenarios.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always return true or false explicitly.","message":"The validate function in ITokenValidator must return a boolean. Returning undefined or null will be treated as false.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Switch to import syntax or set \"type\": \"module\" in your package.json.","cause":"Using CommonJS require() with an ESM-only package.","error":"ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/cryo-server/dist/index.js from /path/to/app.js not supported."},{"fix":"Use import { cryo } from 'cryo-server' instead of import cryo from 'cryo-server'.","cause":"Importing the default export instead of the named export cryo.","error":"TypeError: cryo is not a function"},{"fix":"Provide a valid token validator object with a validate method.","cause":"Passing an empty object instead of an ITokenValidator as the first argument.","error":"TypeError: Cannot read properties of undefined (reading 'validate')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}