Bump deps to latest, fix single-use servers and broken docs - #4
Merged
Merged
Conversation
Update all JSR dependencies to their current releases:
@std/assert 1.0.0 -> 1.0.19
@std/media-types 1.0.1 -> 1.1.0
@std/testing 0.225.3 -> 1.0.20
@std/expect 0.224.5 -> 1.0.20
Replace the deno.land/x/gql@3.0.1 import in the e2e test with
jsr:@deno-libs/gql@4.1.0 — deno.land/x is deprecated and frozen.
graphql stays on ^16.10.0 rather than 17.x: @deno-libs/gql pins
npm:graphql@16.10.0 exactly, and a second copy of graphql in the
module graph trips GraphQL.js' cross-realm instanceof checks
("Cannot use GraphQLSchema from another module or realm"). The
lockfile confirms a single deduped graphql.
Move every dependency into a deno.json import map and reference them
by bare specifier. This clears the 6 pre-existing `no-import-prefix`
lint errors and makes `deno outdated` / `deno update` usable for
future bumps.
Regenerate deno.lock, dropping entries that were no longer reachable
(@std/http, xss, commander, cssfilter, and the deno.land/x/gql
remote hashes).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
makeFetch was unusable for more than one request. Both branches shut the server down after the first response, so a second call hit a dead port -- the repo's own example.ts crashed on request 2 with ECONNREFUSED. Covered by nothing, because every test created a fresh makeFetch. The Deno.HttpServer branch wrapped the request in `new Promise((resolve) => setTimeout(async () => ...))` with no reject path, so anything thrown inside escaped as an unhandled rejection and tore the process down instead of rejecting the returned promise -- an uncatchable failure for callers. Dropping the pointless setTimeout and using a plain async function fixes it. `FetchFunction` accepts `string | URL`, but the URL was interpolated into a template literal, yielding `http://localhost:41655http://example.com/x` and a TypeError. Resolve properly and force the origin to the test server so a path, a relative URL and an absolute URL all reach the handler. Changes: - Host a bare handler per request instead of once per makeFetch(). An instance now serves any number of requests, and one that is never called no longer leaves a server listening. - Stop shutting down a caller-supplied Deno.HttpServer. We do not own it. BEHAVIOUR CHANGE: callers passing their own server must now close it themselves, as they already had to for anything past the first request. - Pass `onListen: () => {}` so the suite stops printing "Listening on http://0.0.0.0:PORT/" once per request. Tests: - Replace six `try { assert } catch (e) { expect(...) }` blocks with expect().toThrow(). The old shape passed whenever nothing was thrown, so the assertions in the catch never ran; a mutation that makes expectStatus stop throwing now fails the suite instead of passing. - Delete 'should throw error if free port cannot be found'. It asserted on an "Unable to get free port" path removed in 74a96e9, and it permanently replaced globalThis.Deno.listen with a throwing stub. - Add coverage for request reuse, caller-owned server lifetime, URL objects and query/hash preservation. Also exclude .claude, .github, .vscode, egg.json and tests from the published package -- .claude/settings.local.json was being uploaded to JSR. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Every code block in the README was broken. Both examples called makeFetch(s) against an undefined `s` instead of the `handler` declared a line above, neither closed its describe() block, and both ended with a bare run() left over from the pre-Deno-2 test runner -- none of it would execute if pasted. Rewrite the examples so they run as written, and cover the parts of the API that had no documentation at all: chained assertions, how expect() dispatches on its arguments, Content-Type-driven body decoding, passing RequestInit, reusing a fetch across requests, and testing an existing Deno.HttpServer (including that the caller now shuts it down). Note that the response body is already consumed by the assertions. Every block was extracted and executed against mod.ts to confirm it passes, including the values in the trailing comments. Point the docs badge and link at JSR -- they referenced doc.deno.land/https/deno.land/x/superfetch, which is the deprecated host. Add the missing install instruction. Delete egg.json. nest.land is defunct, and the manifest still described the package as version 1.0.2 with a stale test command. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
makeFetch no longer shuts down a Deno.HttpServer supplied by the caller, so callers passing their own server must now close it themselves. That is a breaking change to the lifecycle contract, hence a major bump rather than a patch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates every dependency to its current release, then fixes the bugs that surfaced while verifying the update. Four commits, each self-contained.
1.
38f9d0c— bump deps@std/assert@std/media-types@std/testing@std/expectgqldeno.land/x/gql@3.0.1jsr:@deno-libs/gql@4.1.0deno.land/xis deprecated, so the e2e test'sgqlimport moves to JSR.graphqlstays on^16.10.0rather than 17.x:@deno-libs/gqlpinsnpm:graphql@16.10.0exactly, and a second copy of graphql in the module graph trips GraphQL.js' cross-realminstanceofchecks (Cannot use GraphQLSchema from another module or realm). The lockfile confirms a single deduped copy.Dependencies also move into a
deno.jsonimport map, which clears 6 pre-existingno-import-prefixlint errors and makesdeno outdatedusable.deno.lockis regenerated, dropping entries that were no longer reachable (@std/http,xss,commander,cssfilter, and thedeno.land/x/gqlremote hashes).No behaviour change — tests stayed at 8 passed / 29 steps, identical to master.
2.
852f215— fixesAll five bugs pre-date this PR; each was confirmed against unmodified master.
makeFetchwas single-use. Both branches shut the server down after the first response, so a second call hit a dead port. The repo's ownexample.tscrashed on request 2 withECONNREFUSED. Nothing caught it, because every test created a freshmakeFetch. A bare handler is now hosted per request, so an instance serves any number of requests and an unused one never leaves a server listening.Deno.HttpServerbranch wrapped the request innew Promise((resolve) => setTimeout(async () => ...))with no reject path, so anything thrown inside escaped as an unhandled rejection instead of rejecting the returned promise — uncatchable by the caller. ThesetTimeoutserved no purpose and is gone.URLarguments produced a malformed URL.FetchFunctionacceptsstring | URL, but the URL was interpolated into a template literal, yieldinghttp://localhost:41655http://example.com/x. Paths, relative URLs and absolute URLs now all resolve to the test server.try { assert } catch (e) { expect(...) }shape passes whenever nothing is thrown, so the assertions in thecatchnever ran. Replaced withexpect().toThrow().should throw error if free port cannot be foundasserted on anUnable to get free portpath removed in 74a96e9, and permanently replacedglobalThis.Deno.listenwith a throwing stub. Deleted.Also passes
onListen: () => {}so the suite stops printingListening on http://0.0.0.0:PORT/once per request, and excludes.claude,.github,.vscodeand tests from the published package —.claude/settings.local.jsonwas being uploaded to JSR.New coverage for request reuse, caller-owned server lifetime,
URLobjects, and query/hash preservation.Important
Behaviour change: superfetch no longer calls
shutdown()on aDeno.HttpServeryou passed in — that server is yours. Callers must close it themselves, as they already had to for anything past the first request. Given the lifecycle change this is released as 4.0.0 (467bd7b) rather than 3.0.1. Note thatpublish.ymlrunsnpx jsr publishon any push tomaster, so merging this publishes@deno-libs/superfetch@4.0.0.3.
3544164— docsEvery README code block was broken:
makeFetch(s)against an undefinedsinstead of thehandlerdeclared above it, no closing}), and a trailingrun()from the pre-Deno-2 test runner. None of it would execute if pasted.Rewritten, plus documentation for the previously uncovered parts of the API: chained assertions, how
expect()dispatches on its arguments, Content-Type-driven body decoding,RequestInit, reuse, and the caller-owned-server case. Also notes that the body is already consumed by the assertions, sores.json()cannot be called again.The docs badge and link pointed at
doc.deno.land/https/deno.land/x/superfetch; both now point at JSR.egg.jsonis deleted — nest.land is defunct and the manifest still claimed version 1.0.2.Verification
Beyond a green suite, each fix was checked to actually bite:
mod.ts— revertingmod.tsalone gives 5 failures plus a runner crash from the unhandled rejection, so the regression tests are real.expectStatusto never throw now fails the suite; under the oldtry/catchit passed silently.mod.ts, including the values in their trailing comments.example.ts— runs clean, exit 0. It crashed before.deno fmt/lint/checkclean · 10 passed / 33 steps ·deno publish --dry-rundown to 9 files.🤖 Generated with Claude Code