2.8 KiB
2.8 KiB
Runbook: natsClient_JS
Connection Issues
getNats fails to connect
Symptom: connectionStatus lands in error, getNats throws.
Steps:
- Check the resolved URL precedence:
opts.servers→VITE_NATS_URL→config.nats_server_info.url→wss://natsws.yiem.cc(4-specification.md:SP-001). - Verify broker reachability:
nc -z -w5 <nats-host> <nats-port>. - Confirm
nats.wsis available (browser/WSS transport,NFR-101). - Retry after fixing config; the consumer should call
getNatsagain.
Connection stuck after a disconnect
Symptom: Status stays disconnected and does not return to connected.
Steps:
- Confirm
nc.status()is wired to emitdisconnect/reconnect(2-solution_design.md:SD-004). - Check
nc.closed()for a permanent close (4-specification.md:SP-001). - Restart the consuming app to re-establish the shared socket.
References: 4-specification.md:SP-001 (connection), 3-walkthrough.md:#wt-007.
Message Issues
Subscribe receives no messages
Symptom: No onMessage callbacks fire.
Steps:
- Verify the subject string matches the broker's subject exactly.
- Confirm the connection reached
connectedbefore subscribing. - Check the subscription is tracked in the
Map(4-specification.md:SP-002).
sendMsghandlerRequest throws
Symptom: throw new Error(data) or No valid response found.
Steps:
- Confirm the backend returns a
jsontable/dictionarypayload, nottext(4-specification.md:SP-011). - Verify
msghandlerCSR.smartpack/smartunpackare in use (2-solution_design.md:SD-006). - Check the broker envelope format (
4-specification.md:SP-010,SP-011).
reply handler produces no response
Symptom: Requests to the subject time out.
Steps:
- Confirm
handlerreturns a value that gets published onm.subject(4-specification.md:SP-005). - Verify the subject is not also consumed by a
requeston the same endpoint.
Error Code Reference
| Error | Symptom | Action | Reference |
|---|---|---|---|
error status |
getNats failed |
Fix URL/config, retry | 4-specification.md:SP-001 |
text msghandler payload |
sendMsghandlerRequest throws |
Confirm backend returns dictionary/jsontable | 4-specification.md:SP-011 |
| decode error | subscription message dropped | Handled by per-message guard (NFR-302) | 4-specification.md:SP-002 |
Escalation
- If the shared socket never reconnects (NFR-102), treat the broker as down and page the backend
team; the library only reports state via
connectionStatus. - Contact: backend/NATS on-call via the
nats_client_reconnect_ratealert.
Post-Incident
- Review logs for root cause (
[NATS] ...lines). - Update this runbook if a new failure mode appears.
- Link findings to
6-validation.mdso the case is covered by a test.