Repository navigation
workerd: test tiers on local workerd and the Cloudflare edge, polyfill and Deno TLS fixes - #151
Merged
Merged
Conversation
okomarov
force-pushed
the
cf-node-net
branch
3 times, most recently
from
October 18, 2026 17:35
d46a0c5 to
b7e3e7d
Compare
This was referenced Oct 18, 2026
Closed
… an N reply (#152, #153) The cloudflare:sockets polyfill had no pause() or resume(). COPY TO calls resume() on its first read and pause() under backpressure, so in workerd it rejected with "socket.resume is not a function" (porsager#975), and subscribe() never delivered. The read loop now waits after a chunk while the socket is paused. With ssl: 'prefer', a server that answers N to the SSLRequest left the socket unread: readFirst() took that one byte and nothing started the read loop, so the connection ended in CONNECT_TIMEOUT. readFirst() now starts the loop unless the reply is S, where the TLS upgrade starts its own.
Deno.startTls takes alpnProtocols, so the Node-style ALPNProtocols option was dropped and PostgreSQL 18 closed direct TLS connections that offered no ALPN.
On workerd, tls.connect() throws for rejectUnauthorized: false and ALPN-free unsupported options, ignores ca, and does not default servername from the host. tlsConfig now gives workerd the socket, the server name (ssl.servername, or the host when it is not an IP address) and ALPN for direct negotiation, and nothing else, so certificates are always verified there, as they are with the cloudflare:sockets polyfill.
…cross compatibility dates The workerd job ran Wrangler 4.123.0 (workerd 1.20260811.1) at compatibility date 2025-01-01 only, one wrangler dev process per scenario. It now runs Wrangler 4.151.1 (workerd 1.20261012.1) through createTestHarness(), which Cloudflare's testing docs recommend: one harness per build and date, reset before each scenario, with unhandled rejections and uncaught errors read from getLogs(). The port selection, readiness polling and port-conflict retry are gone with the processes, so #54 cannot recur. workerd inherits the Node process environment, so SSL_CERT_FILE stays set while the harness restarts it for end-tls. CI runs every scenario on both builds, the generated cf/ build over cloudflare:sockets and src/ over workerd's node:net and node:tls, at 2025-01-01, 2025-09-15 (node:fs, node:os and process v2 on by default) and 2026-10-12, the newest date that runtime accepts. New scenarios, each one checked in real workerd: - copy-out: a COPY TO stream read by a slow consumer, which pauses and resumes the socket. - ssl-prefer-declined: ssl: 'prefer' against a server without SSL. - tls-untrusted-ca: a certificate workerd does not trust must fail with the certificate error, not CONNECT_TIMEOUT. - subscribe: one logical replication insert delivered. The CI clusters run with wal_level = logical and a replication pg_hba entry. - diagnostics-channel: node:diagnostics_channel publish and tracePromise, for the event layer in #73. Each result counts the close-time rejections it saw (#1), under both messages: "Stream was cancelled" and, from workerd 1.20261008.1, "This socket has been closed". The worker also returns them in its response. WORKERD_KNOWN_FAILURES lists scenarios expected to fail and the run fails if one passes; the only entry is tls-untrusted-ca before 2026-10-12, where workerd itself reports an unhandled "Network connection lost.". test:workerd installs the pinned Wrangler without saving it, as the lint job does with ESLint; /node_modules/ is now ignored.
PostgreSQL 18 is the current release; the Node matrix keeps 15, 16 and 17. The Deno build of the test bootstrap now ignores psql warnings as the Node one does, since PostgreSQL 18 warns when it stores an MD5 password.
…eon and Hyperdrive (#154) Local workerd cannot show what only the edge does: production sockets, TLS to a public certificate chain, SNI and close behaviour on real connections. The workerd-edge workflow deploys the test worker as a Cloudflare Preview per same-repo pull request, push to main and tag, at compatibility dates 2025-01-01 and 2026-10-12, and calls every database scenario on both builds over HTTPS. It targets the deployment URL from wrangler preview --json, which always serves this run's deployment; the Preview URL can briefly serve the previous one. A per-run token, uploaded with --secrets-file, guards it. Previews are deleted when the pull request closes. The Preview bundles the cf/ and src/ builds side by side (?build=cf|src) and connects to the Neon database in the NEON_DATABASE_URL and NEON_POOLED_URL secrets, routed by the SNI the edge sends. Edge-only scenarios: ssl-verify (Neon's proxy ends TLS, so it asserts that a plaintext connection is refused rather than reading pg_stat_ssl) and pooled (Neon's PgBouncer endpoint). Fixture scenarios stay local. Subscribe publishes only its own table, since CREATE PUBLICATION FOR ALL TABLES needs a superuser that hosted databases do not grant. Two Hyperdrive configurations, caching off, sit in front of Neon's direct and pooled endpoints. Each hyperdrive round opens a client with prepare: true and max: 5, as Cloudflare's guide recommends, and runs 50 concurrent insert and select pairs. Five rounds per build by default; a manual dispatch takes a higher count.
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.
Part of the Cloudflare round (#15). Supersedes #150.
Exports are not changed yet; the default flips in a follow-up once this lands.
Fixes #54, fixes #152, fixes #153.