Skip to content

test(rivetkit): re-enable gateway URL and direct-registry coverage#4659

Closed
NathanFlurry wants to merge 1 commit intobreak-up/keep-error-exposure-consistentfrom
break-up/reenable-gateway-url-coverage
Closed

test(rivetkit): re-enable gateway URL and direct-registry coverage#4659
NathanFlurry wants to merge 1 commit intobreak-up/keep-error-exposure-consistentfrom
break-up/reenable-gateway-url-coverage

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 14, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 15, 2026

PR Review (updated): test(rivetkit): re-enable gateway URL and direct-registry coverage

This is an updated review reflecting the latest changes.

Summary

This PR re-enables two test suites (raw-http-direct-registry and raw-websocket-direct-registry), rewrites driver-engine-ping.test.ts to use the serverless runner pattern, adds a waitForClientWarmup readiness barrier, adds retry logic to refreshRunnerMetadata, re-enables the dynamic registry test variant, and switches engine driver tests to describe.sequential.


Significant: Silent swallow of refreshRunnerMetadata errors

In driver-engine.test.ts (~line 196), all errors from refreshRunnerMetadata are caught and discarded. A permanent failure (wrong token, misconfigured endpoint) will be invisible and any downstream test failure will be misattributed. Consider logging the caught error at warn level so the CI trace retains a breadcrumb without blocking setup.

Significant: Non-null assertion on serverlessHandleStart

In src/test/mod.ts (~line 168) and driver-engine-ping.test.ts, the call actorDriver.serverlessHandleStart!(ctx) will throw an unhelpful TypeError if the driver does not implement this method. A guard returning HTTP 501 with a clear message would make failures immediately actionable.

Moderate: Duplicated helpers across test files

refreshRunnerMetadata and closeNodeServer appear in src/test/mod.ts, driver-engine.test.ts, and driver-engine-ping.test.ts. waitForOpen appears in driver-engine-ping.test.ts and raw-websocket-direct-registry.ts with differing listener cleanup quality (ping file properly cleans up; WebSocket file uses once:true without cleaning the other paths). buildGatewayRequestUrl appears in raw-http-direct-registry.ts and driver-engine-ping.test.ts with differing double-prefix guards. These should be consolidated into a shared tests/engine-test-utils.ts.

Moderate: serverless config block duplicated verbatim

The serverless runner config block is duplicated between src/test/mod.ts (~line 185) and driver-engine-ping.test.ts (~line 1665). Extracting it into a shared constant prevents the copies from diverging silently.

Minor: waitForClientWarmup uses a fixed key across parallel tests

The constant key driver-test-warmup works today because each test has its own namespace/pool, but a per-test ID would make isolation explicit and robust against future config changes.

Minor: Retry sleep uses raw setTimeout instead of antiox

Per CLAUDE.md, antiox is the preferred TypeScript concurrency primitive. The retry loops in refreshRunnerMetadata use raw setTimeout directly.

Minor: Missing conn_params test in the HTTP gateway suite

raw-http-direct-registry.ts does not include a conn_params test (the old code had one via HEADER_CONN_PARAMS). The WebSocket suite does test conn params. If the HTTP gateway path supports conn_params, this coverage gap should be tracked.


Positive Observations

  • waitForClientWarmup with a ping() action on a dedicated warmup actor is a much cleaner readiness barrier than the previous setTimeout(250).
  • describe.sequential for the engine driver suite is correct for tests that share a single engine process.
  • buildGatewayWebSocketUrl in raw-websocket-direct-registry.ts properly handles query-string passthrough.
  • AbortSignal.timeout(2_000) per retry attempt in refreshRunnerMetadata prevents a single stalled request from consuming the full retry budget.
  • Re-enabling the dynamic registry variant closes genuine coverage that was dark.
  • Namespace creation with 409-tolerance in ensureNamespaceExists is correct for idempotent test setup.

Review generated by Claude Sonnet 4.6

@claude
Copy link
Copy Markdown

claude Bot commented Apr 15, 2026

PR 4659 Review: test(rivetkit) re-enable gateway URL and direct-registry coverage

Overview

This PR adds two new test scenarios to the engine driver smoke test suite and a minimal warmupActor fixture:

  1. HTTP ping via gateway URL - exercises the getGatewayUrl() routing to /request/<path>
  2. WebSocket echo via gateway URL - exercises the getGatewayUrl() routing to /websocket/<path>
  3. warmupActor fixture - a minimal actor with a single ping action, added to the static registry

Issues

Unexplained initial-message wait before sending ping

In the new WebSocket gateway test, an await new Promise waits for an incoming message before the ping is sent. The original non-gateway WebSocket test sends the ping immediately after waitForOpen with no initial-message wait. If the gateway or actor does not send anything on connect, this promise will never resolve and the test will time out. If it does send something (e.g. a connection-ack frame), that behavior needs a comment explaining it.

Suggestion: Add a comment such as // wait for connection-ack from gateway or remove the block if not needed.

Listener registered after send (pre-existing, worth noting)

In both the existing and new WebSocket tests, the message listener for the pong is registered after ws.send is called. In practice this works because network RTT keeps the reply from arriving before the microtask registers the listener, but it is a latent race. The safer pattern is to register the listener before sending.

No cleanup on failure

ws.close() is called at the end of each test but is not guarded by try/finally. If the test throws before reaching ws.close(), the connection leaks. A try/finally or Vitest onTestFinished would be safer. The same issue exists in the pre-existing tests; fixing them in the same change would be a clean-up win.

warmupActor purpose is unclear

warmupActor is added to the static registry but is not referenced in any of the new tests. A short comment in registry-static.ts or warmup.ts explaining why this actor exists would help future readers.


Minor Observations

  • buildGatewayRequestUrl / buildGatewayWebSocketUrl - clean URL manipulation using new URL(), good practice.
  • encodings: json filter - limiting gateway tests to JSON encoding is reasonable for path-routing coverage.
  • waitForOpen - correct; no TOCTOU risk in single-threaded JS since listener registration and readyState check are synchronous.
  • Fixture structure - actors/warmupActor.ts re-exporting from ../warmup.ts matches the existing pattern in the fixture directory.

Summary

The main concern is the unexplained initial-message await in the WebSocket gateway test. If the actor/gateway does not send a frame on connect, the test will hang. The other points (listener ordering, missing try/finally) are lower priority. The warmupActor needs a comment explaining its purpose.

@NathanFlurry NathanFlurry force-pushed the 04-14-fix_rivetkit_add_lifecycle_error_retry_and_gateway_http_routing branch from cde8213 to 8cf4223 Compare April 27, 2026 07:53
@NathanFlurry NathanFlurry force-pushed the break-up/reenable-gateway-url-coverage branch from 6cbcfce to c4f0322 Compare April 27, 2026 08:31
@NathanFlurry NathanFlurry force-pushed the 04-14-fix_rivetkit_add_lifecycle_error_retry_and_gateway_http_routing branch from 6987ecc to d17056c Compare April 27, 2026 17:35
@NathanFlurry NathanFlurry force-pushed the break-up/reenable-gateway-url-coverage branch from c4f0322 to 6b63eed Compare April 27, 2026 17:35
@NathanFlurry NathanFlurry force-pushed the 04-14-fix_rivetkit_add_lifecycle_error_retry_and_gateway_http_routing branch from d17056c to df32e78 Compare April 27, 2026 19:06
@NathanFlurry NathanFlurry force-pushed the break-up/reenable-gateway-url-coverage branch from 6b63eed to 392102e Compare April 27, 2026 19:06
@NathanFlurry NathanFlurry changed the base branch from 04-14-fix_rivetkit_add_lifecycle_error_retry_and_gateway_http_routing to graphite-base/4659 April 27, 2026 19:30
@NathanFlurry NathanFlurry force-pushed the break-up/reenable-gateway-url-coverage branch from 392102e to e81836a Compare April 27, 2026 19:30
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4659 to break-up/keep-error-exposure-consistent April 27, 2026 19:31
@NathanFlurry NathanFlurry force-pushed the break-up/reenable-gateway-url-coverage branch 2 times, most recently from e5ca28f to 49982a7 Compare April 27, 2026 20:48
@NathanFlurry NathanFlurry force-pushed the break-up/reenable-gateway-url-coverage branch from 49982a7 to e6b5003 Compare April 27, 2026 21:38
@NathanFlurry NathanFlurry force-pushed the break-up/keep-error-exposure-consistent branch from 079403b to eb49dfb Compare April 27, 2026 21:38
@NathanFlurry
Copy link
Copy Markdown
Member Author

Landed in main via stack-merge fast-forward push. Commits are in main; closing to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant