|
3 | 3 | * (#4854), with its default limits: fetching a `data:` or local `http:` URL, |
4 | 4 | * returning the gzipped file as a resource link or an embedded resource, |
5 | 5 | * registering it for later reads, and the errors for bad protocols, oversized |
6 | | - * or empty responses and failed fetches. It also pins #4808: two sessions that |
7 | | - * use the same file name evict each other's resource. The configurable limits |
8 | | - * are in `gzip-limits.test.ts`. |
| 6 | + * or empty responses and failed fetches. It also guards #4808: two sessions |
| 7 | + * that use the same file name each keep their own resource. The configurable |
| 8 | + * limits are in `gzip-limits.test.ts`. |
9 | 9 | */ |
10 | 10 | import { createServer as createHttpServer, type Server } from "node:http"; |
11 | 11 | import { once } from "node:events"; |
@@ -150,24 +150,21 @@ describe("gzip-file-as-resource", () => { |
150 | 150 | expect(gunzipSync(blob).toString()).toBe("second"); |
151 | 151 | }); |
152 | 152 |
|
153 | | - // KNOWN BUG #4808: pins current (wrong) behavior; the fix changes this assertion. |
154 | | - it("evicts another session's resource of the same name (#4808)", async () => { |
155 | | - // Characterization of #4808: session resources are tracked in one |
156 | | - // module-level map keyed by URI, so the second session's registration |
157 | | - // removes the first session's resource from the first session's server. |
| 153 | + it("keeps each session's resource when two sessions use the same name (#4808)", async () => { |
| 154 | + // Regression guard for #4808: session resources are tracked per server, |
| 155 | + // so the second session's registration leaves the first session's |
| 156 | + // resource (and its content) in place. |
158 | 157 | const a = await open(); |
159 | 158 | const b = await open(); |
| 159 | + const second = `data:text/plain;base64,${Buffer.from("from b").toString("base64")}`; |
160 | 160 | await gzip(a, { name: "shared.gz", data: DATA_URI }); |
161 | | - await gzip(b, { name: "shared.gz", data: DATA_URI }); |
| 161 | + await gzip(b, { name: "shared.gz", data: second }); |
162 | 162 |
|
163 | | - await expect( |
164 | | - a.client.readResource({ uri: "demo://resource/session/shared.gz" }), |
165 | | - ).rejects.toThrow("Resource demo://resource/session/shared.gz not found"); |
166 | | - expect( |
167 | | - gunzipSync( |
168 | | - await readBlob(b, "demo://resource/session/shared.gz"), |
169 | | - ).toString(), |
170 | | - ).toBe(TEXT); |
| 163 | + const uri = "demo://resource/session/shared.gz"; |
| 164 | + expect(gunzipSync(await readBlob(a, uri)).toString()).toBe(TEXT); |
| 165 | + expect(gunzipSync(await readBlob(b, uri)).toString()).toBe("from b"); |
| 166 | + const { resources } = await a.client.listResources(); |
| 167 | + expect(resources.map((r) => r.uri)).toContain(uri); |
171 | 168 | }); |
172 | 169 |
|
173 | 170 | it("rejects a URL that is not http, https or data", async () => { |
|
0 commit comments