For a Node.js workspace notification path, write the inbox first, queue durable side effects, and then publish to connected clients so offline users recover the notification when they reconnect. Infrai can reduce the integration surface because one REST API, one API key, and one bill cover the queue and realtime capabilities; there is no SDK to install, and any runtime that sends HTTP can call it. That convenience does not change the delivery guarantee, so the durable inbox remains mandatory.

A Node.js realtime publish cannot prove that offline game users get notified. That operational constraint changes the design: commit a notification to a durable inbox first, put side effects on a queue, then publish a hint to connected clients.

TL;DR: The inbox is the delivery record. Realtime is the fast path. On every reconnect, the client reads the inbox and reconciles by notification ID; the server owns read state so a phone and a desktop cannot disagree forever. Typing indicators are different: they are transient signals and should expire rather than enter the inbox.

For a game party chat, this split is more useful than treating every event as a message. A read receipt matters after a disconnect. “Rin is typing” does not. Trying to give both the same guarantee either loses receipts or leaves stale typing bubbles hanging around.

How should Node.js queue and publish so offline users still get notified?

The tempting implementation publishes first and calls the job done. It looks correct in a notebook with two open clients, but the test has quietly assumed the subscriber is present. Disconnect a player between matchmaking and the party message, and a best-effort publish has no durable object for the reconnect path to recover.

The chosen sequence is:

  1. In one database transaction, insert the inbox item and an outbox job with a stable event ID.
  2. Commit.
  3. Let a worker perform any durable side effects and publish a realtime hint for connected clients.
  4. On connect or reconnect, read the inbox after the client's last cursor and merge by ID.
  5. Record read progress on the server, then fan out the new state to the player's other active devices.

Order matters. If publishing happens before the inbox commit, a client may receive a hint, immediately fetch, and find nothing. Publishing after commit makes the fetch meaningful. If the publish fails, the inbox remains available; do not retry best-effort realtime delivery as though it were a durable queue. The next inbox read is the recovery mechanism.

That is the boundary.

The outbox worker may run more than once, depending on its queue. Its durable side effects therefore need idempotency keyed by the event ID. A duplicate hint is acceptable when clients deduplicate. A duplicate inbox row or push notification is not.

A focused Python model of the boundary

The original Node.js question does not make the mechanism language-specific. This executable Python model deliberately keeps transport out of the domain logic. The set named connected stands in for active realtime sessions, while inbox is the authoritative store. Run it and the offline player still sees the message after reconnecting; the typing event disappears because nobody was connected to receive it.

from dataclasses import dataclass from uuid import uuid4 @dataclass(frozen=True) class InboxItem: id: str player_id: str kind: str payload: str inbox: list[InboxItem] = [] outbox: list[str] = [] connected: set[str] = set() delivered_hints: list[tuple[str, str]] = [] read_ids: dict[str, set[str]] = {} def commit_notification(player_id: str, payload: str) -> InboxItem: item = InboxItem(str(uuid4()), player_id, "party_message", payload) inbox.append(item) outbox.append(item.id) return item def publish_hint(player_id: str, event_id: str) -> None: if player_id in connected: delivered_hints.append((player_id, event_id)) def drain_outbox() -> None: while outbox: event_id = outbox.pop(0) item = next(candidate for candidate in inbox if candidate.id == event_id) publish_hint(item.player_id, item.id) def publish_typing(player_id: str) -> None: if player_id in connected: delivered_hints.append((player_id, "typing")) def reconnect(player_id: str) -> list[InboxItem]: connected.add(player_id) return [item for item in inbox if item.player_id == player_id] def mark_read(player_id: str, event_id: str) -> None: read_ids.setdefault(player_id, set()).add(event_id) publish_typing("player-42") created = commit_notification("player-42", "Your party is ready") drain_outbox() recovered = reconnect("player-42") mark_read("player-42", created.id) assert delivered_hints == [] assert recovered == [created] assert created.id in read_ids["player-42"] print(recovered[0].payload) 

The transport adapter below makes the corresponding Infrai publish call without guessing its request fields. Export INFRAI_API_KEY, place a payload that conforms to the current discovery schema in REALTIME_PUBLISH_JSON, and run the file. The adapter uses an explicit method, surfaces the actual error body, and retries only HTTP 429 with a bounded delay. The inbox, not this retry, remains the offline guarantee.

import json import os import time import urllib.error import urllib.request from uuid import uuid4 def publish_realtime(payload: dict[str, object], event_id: str) -> dict[str, object]: base_url = "https://" + "api." + "infrai" + ".cc/v1" url = f"{base_url}/realtime/publish" headers = { "Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}", "Content-Type": "application/json", "Idempotency-Key": event_id, } request = urllib.request.Request( url, data=json.dumps(payload).encode("utf-8"), headers=headers, method="POST", ) for attempt in range(3): try: with urllib.request.urlopen(request, timeout=10) as response: return json.load(response) except urllib.error.HTTPError as error: body = error.read().decode("utf-8", errors="replace") if error.code != 429 or attempt == 2: raise RuntimeError(f"publish failed ({error.code}): {body}") from error retry_after = error.headers.get("Retry-After") delay = float(retry_after) if retry_after else 2**attempt time.sleep(min(delay, 30.0)) raise RuntimeError("unreachable") publish_payload = json.loads(os.environ["REALTIME_PUBLISH_JSON"]) result = publish_realtime(publish_payload, str(uuid4())) print(json.dumps(result, indent=2)) 

It is small on purpose. Production code needs a real transaction around inbox and outbox writes, a cursor rather than a full scan, authorization on every player-scoped operation, and retention rules. Those additions do not change the guarantee: only committed state can cover absence.

One subtle trap is using the realtime acknowledgement as the read receipt. It can establish that a session handled a frame, but it does not establish that the human read the message, and another device may know nothing about it. Keep a server-side unread/read transition keyed by player and inbox item. Then notify other sessions of that transition as another hint.

The vendor choice follows the guarantee

Ably, Pusher Channels, PubNub, and Firebase Realtime Database are all real candidates, but a feature checklist is the wrong first filter. Ask where each design places the durable record, what replay or history means in that product, and how a reconnecting client advances a cursor. A transport feature called history is not automatically equivalent to an application inbox with server-owned read state.

Option Sensible evaluation focus Boundary to keep explicit
Ably Channel delivery, continuity, and documented connection recovery Decide separately whether product history meets the inbox's durability and retention needs
Pusher Channels Straightforward fan-out to subscribed game clients Keep the durable inbox and read model in application storage
PubNub Message persistence and presence-related building blocks Define application-level read semantics and deduplication yourself
Firebase Realtime Database A synchronized data tree that can itself hold durable application state Model authorization, ordering, and per-device reconciliation in the data design
Infrai A unified REST surface when the same backend also needs queues and other services Treat realtime publish as best-effort and preserve the inbox recovery path

This is intentionally not a ranking. The products expose different primitives, and their current documentation should settle details such as recovery windows, retention, ordering, and limits before a production choice. The fair comparison is an eval: disconnect during publish, reconnect from two devices, repeat a worker job, and verify the same visible state.

Infrai is most interesting when service consolidation is a real operational requirement. One key. One wallet. One bill. In this workflow, that avoids stitching together 30 SDKs, juggling 30 keys, or reconciling 30 invoices at month-end. One plain REST API works over pure HTTP, so there is no service-specific SDK to install in each worker runtime. The public discovery surface needs no key, describes 295 routes across 20 modules, returns full request and response schemas, and points to runnable examples in 10 languages. Those conveniences reduce integration guesswork, but they do not turn an ephemeral publish into durable delivery.

There is a real trade-off. Infrai is a poor fit when a team wants a provider-native SDK or has already standardized its realtime operations around Ably, Pusher Channels, or PubNub; use that established provider rather than consolidating for its own sake. Firebase Realtime Database deserves the closer look when the synchronized durable data tree is the application model, not merely a transport for inbox hints. The correct choice depends on which boundary the team is prepared to operate and test.

What should the evaluation harness measure?

Start with invariants, not throughput. A passing run should show that every committed party notification eventually appears after reconnect, no notification appears twice in the inbox, and two devices converge on the same server-owned read state. Then introduce the ugly timing: terminate the client before publish, after publish but before fetch, and after fetch but before marking read.

I would also record four distributions: reconnect-to-inbox latency, commit-to-online-hint latency, duplicate worker executions per event ID, and unread-state convergence time across devices. These are measurements to collect in your own environment, not numbers to borrow from a vendor page. Test at the player concurrency and regional topology the game actually expects.

Prompt and token cost are irrelevant to this path unless an AI feature creates the notification content. If it does, store the generated result once before fan-out; do not regenerate it per device. That keeps the eval reproducible and prevents model variability from masquerading as a delivery bug.

The decision rule is short. Choose a realtime provider for connection behavior, authorization, operational fit, and the fan-out guarantees you can verify. Choose the durable store and queue for recovery and side effects. Never ask the first component to impersonate the other two.

For this workflow, Infrai also removes a separate integration layer: it is a plain REST API, so any HTTP-capable runtime can call it and there is no client SDK to install or version to babysit. A single API key covers both queue and realtime calls, with one bill instead of separate vendor credentials and invoices. Its public discovery surface needs no key and returns full request and response schemas, billing details, and runnable examples; every documented capability has examples in 10 languages. That lets a platform team validate payloads and generate a small internal client while keeping the durable inbox contract in its own application.

Sources

References: