Registry / devops / grpc-server-js

grpc-server-js

JSON →
library0.5.0jsnpmunverified

Pure JavaScript gRPC server implementation (v0.5.0) that uses Node's built-in http2 module, eliminating C++ dependencies and native compilation. It aims to be largely compatible with the official grpc.Server API, supporting unary, server/client streaming, bidirectional calls, deadline/cancellation, gzip/deflate compression, server credentials, and metadata. No production dependencies. Released under active development with periodic updates; key differentiator is zero native dependencies, making it suitable for environments where native modules are problematic. However, it is not yet stable (pre-1.0) and has some API deviations (async bind(), missing addProtoService()).

npm install grpc-server-js
INSTALL
IMPORT
SIG · GRPC-SERVER-JS
G
grpc-server-js
devopsjavascriptv0.5.0
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.

Server
import { Server } from 'grpc-server-js'
const grpc = require('grpc-server-js'); const server = new grpc.Server()
The package exports a named Server class, not a default object. Use named import for ESM.
ServerCredentials
import { ServerCredentials } from 'grpc-server-js'
const ServerCredentials = require('grpc-server-js').ServerCredentials
Correct import for creating secure/insecure credentials.
Metadata
import { Metadata } from 'grpc-server-js'
const { Metadata } = require('grpc-server-js')
CommonJS require destructuring works as well; no wrong pattern if using CJS.
loadPackageDefinition
import { loadPackageDefinition } from 'grpc-server-js'
For loading protobuf definitions, similar to @grpc/grpc-js.

Creates a gRPC server using grpc-server-js, loads a .proto file, adds a service, binds to a port, and starts listening.

import { Server, ServerCredentials } from 'grpc-server-js'; import { loadPackageDefinition } from '@grpc/proto-loader'; import protoLoader from '@grpc/proto-loader'; const packageDefinition = protoLoader.loadSync('path/to/helloworld.proto', { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true }); const helloProto = loadPackageDefinition(packageDefinition).helloworld; function sayHello(call, callback) { callback(null, { message: 'Hello ' + call.request.name }); } const server = new Server({ 'grpc.max_receive_message_length': 1024 * 1024 }); server.addService(helloProto.Greeter.service, { sayHello }); const bindResult = await server.bindAsync('0.0.0.0:50051', ServerCredentials.createInsecure()); server.start(); console.log('Server running on port', bindResult);
Debug
Known issues
breakingServer.prototype.bind() is async: must use await or .then()
fix
Use await server.bindAsync(port, creds) instead of synchronous bind().
affects: >=0.1.0
deprecatedServer.prototype.addProtoService() is not implemented
fix
Use addService() with a loaded service definition from @grpc/proto-loader.
affects: >=0.1.0
gotchaDoes not support all grpc.Server options; check compatibility
fix
Only options listed in README are supported; others may be ignored or cause errors.
affects: <0.6.0
gotchaNo built-in reflection or channelz support
fix
Use third-party tools or @grpc/reflection if needed.
affects: >=0.1.0
gotchaRequires Node >=10.10.0 due to http2 module
fix
Update Node.js to >=10.10.0.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: server.bind is not a function
bind() is async and must be called as bindAsync() in newer versions or awaited.
fix
Use await server.bindAsync(port, ServerCredentials.createInsecure())
Error: No method found for /helloworld.Greeter/SayHello
Service definition not correctly loaded or service name mismatch.
fix
Ensure proto file is loaded correctly and service name matches: usually 'package.ServiceName'.
Error: The 'grpc.max_receive_message_length' option is not supported
Option not implemented in this version or misspelled.
fix
Check supported options list; use exact strings from README.
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources