Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions js/net/src/origin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,22 @@ test("a received route its announcer ends ends, and one its session loses goes o
origin.close();
});

test("a route received through a scoped handle goes offline when the handle closes", async () => {
const origin = new Producer();
const announced = origin.consume().routes();

const scoped = origin.scope(Path.empty(), new Path.Patterns([Path.Pattern.all()]));
const route = wireOf(scoped).receive(Path.from("room"), WireRoute.default);
expect(await announced.next()).toMatchObject({ prefix: Path.from("room"), kind: "start" });

scoped.close();
expect(await announced.next()).toMatchObject({ prefix: Path.from("room"), kind: "offline" });
route.close();

announced.close();
origin.close();
});

test("announced keeps a broader covering route at its prefix", async () => {
const origin = new Producer();
const consumer = origin.consume();
Expand Down
16 changes: 9 additions & 7 deletions js/net/src/origin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1688,16 +1688,15 @@ export class Producer implements Table {
this.#state.rebuildOriginated();
this.#state.refreshPrefix(prefix);
};
// A received route torn down by any path (its handle, or the scoped handle it came through)
// was lost with its session; only its announcer ending it on the wire withdraws it.
let lost = !originated;
const release = this.#hold(() => {
if (!ended) entry.lost = lost;
ended = true;
this.#state.servers.delete(server);
remove(() => server.close());
});
// A received route its handle closes was lost with its session, unless its announcer ended it.
const close = (lost: boolean) => {
if (!ended) entry.lost = lost;
release();
};
// A route made after its origin (or this handle) closed is born retracted.
if (this.#borrowed?.closed || this.#state.closed.peek() !== undefined) {
ended = true;
Expand Down Expand Up @@ -1752,8 +1751,11 @@ export class Producer implements Table {
},
announced: () => inserted && this.#state.closed.peek() === undefined,
change: (changed) => update(WireRoute.normalize({ ...entry.route.peek(), ...changed })),
close: () => close(!originated),
end: () => close(false),
close: release,
end: () => {
lost = false;
release();
},
info: () => (inserted && this.#state.closed.peek() === undefined ? entry.route.peek() : undefined),
update: (next) => {
// A route naming no instance keeps the one it serves.
Expand Down
4 changes: 0 additions & 4 deletions quest/m1/offline-cursor-fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,3 @@ Caused by: [moq-dev/moq#8375](https://github.com/moq-dev/moq/pull/8375), which
introduced the offline reason and left this branch on End.

Public API: none. Wire: none.

## Related

- [A scoped JS handle that closes reports its routes offline](/quest/m1/offline-js-handle.md) - the same misreport in `js/net`
39 changes: 0 additions & 39 deletions quest/m1/offline-js-handle.md

This file was deleted.