Registry / messaging / nuxt-plugins-grpc-web-client-stream

nuxt-plugins-grpc-web-client-stream

JSON →
library2.0.9jsnpmunverified

A Nuxt/Vue plugin for gRPC-Web client streaming with automatic retry. Version 2.0.9, stable, provides simple API to subscribe to gRPC server-side streams with reconnection logic. Differentiator: designed specifically for Nuxt 2 / Vue 2 ecosystem, handles metadata and host configuration easily.

npm install nuxt-plugins-grpc-web-client-stream
INSTALL
IMPORT
SIG · NUXT-PLUGINS-GRPC-
N
nuxt-plugins-grpc-web-client-stream
messagingjavascriptv2.0.9
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.

subscribeEvents
import subscribeEvents from 'nuxt-plugins-grpc-web-client-stream'
const subscribeEvents = require('nuxt-plugins-grpc-web-client-stream')
Default export. ESM import is correct; require might break depending on environment.
GrpcWebClientStream (if re-export type)
import type { GrpcWebClientStream } from 'nuxt-plugins-grpc-web-client-stream'
Type import if package exposes TypeScript types.
subscribeEvents (named)
import { subscribeEvents } from 'nuxt-plugins-grpc-web-client-stream'
Package only has default export; named import does not exist.

Shows how to import and use subscribeEvents to initiate a gRPC-Web client stream with callbacks for messages and unknown events.

import subscribeEvents from 'nuxt-plugins-grpc-web-client-stream' import { grpc } from '@grpc/grpc-js' import { CaseMgm, SubscribeEventRequest } from './generated/proto' async function startStream() { const host = 'https://example.com' try { await subscribeEvents( { service: CaseMgm.SubscribeEvent, request: SubscribeEventRequest.create(), grpc, host, }, { onMsgFun: (val) => console.log('Message:', val), onUnknownFun: (val) => console.log('Disconnected:', val), } ) } catch (error) { if (error.status) { console.log('重连失败,请检查网络链接!') } } }
Debug
Known issues
gotchaThe 'grpc' property must be the @grpc/grpc-js object; using a different gRPC library will cause runtime errors.
fix
Ensure you import grpc from '@grpc/grpc-js' and pass it as the 'grpc' property.
affects: >=1.0.0
gotchaThe 'metadata' prop is optional but if passed, it must be a valid grpc.Metadata object; otherwise streaming may fail silently.
fix
Initialize metadata with new grpc.Metadata() and pass it.
affects: >=1.0.0
gotchaThis package is designed for Nuxt 2 / Vue 2; not tested with Vue 3 or Nuxt 3.
fix
Use only with Nuxt 2 / Vue 2 projects.
affects: 2.0.9
gotchaThe host must include protocol (http/https); missing protocol leads to connection failure.
fix
Always prefix host with 'http://' or 'https://'.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'status' of undefined
Catch block expects error object with 'status' property, but error might be a string or null.
fix
Check error type: if (error && error.status) { ... }
Error: gRPC failed to connect
Host not accessible or wrong protocol.
fix
Ensure host is reachable and includes 'https://' or 'http://'.
Error: No service defined
Missing 'service' property in first argument.
fix
Pass an object with 'service' key containing a valid gRPC service definition.
Upgrade
Version history
2.0.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
nuxt-plugins-grpc-web-client-stream — npm install nuxt-plugins-grpc-web-client-stream · libregistry