Skip to content

Loopback service stubs accept a dynamic version (cohort) parameter - #6111

Merged
sohpeach merged 1 commit into
mainfrom
swallace/loopback-service-binding-cohorts
Feb 25, 2026
Merged

sohpeach merged 1 commit into
mainfrom
swallace/loopback-service-binding-cohorts

Conversation

@sohpeach

@sohpeach sohpeach commented Feb 19, 2026 •

Copy link
Copy Markdown
Member

Similar to props, this allows a worker to call the service stub as a function, passing along the given version information (currently only a cohort string) to the runtime.

workerd's server implementation currently ignores this information, so the test included in this commit is very minimal. We could come up with a better test once we've decided how this information will be exposed to the worker, assuming it also makes sense in the workerd runtime. The internal codebase tests this feature in more depth.

The feature is behind the experimental enable_version_api flag. Usage looks like:
let service = ctx.exports.default({ version: { cohort: "blah" } });

@sohpeach
sohpeach requested a review from jp4a50 February 19, 2026 12:54
@sohpeach
sohpeach requested review from a team as code owners February 19, 2026 12:54
Comment thread src/workerd/server/server-test.c++ Outdated
Comment thread src/workerd/server/server-test.c++ Outdated
Comment thread src/workerd/io/compatibility-date.capnp Outdated
@sohpeach
sohpeach force-pushed the swallace/loopback-service-binding-cohorts branch from 47269b7 to 5e97e28 Compare February 20, 2026 13:35
@github-actions

github-actions Bot commented Feb 20, 2026 •

Copy link
Copy Markdown

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

@sohpeach
sohpeach force-pushed the swallace/loopback-service-binding-cohorts branch from 5e97e28 to 117d265 Compare February 20, 2026 14:27
@codspeed

codspeed Bot commented Feb 20, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 70 untouched benchmarks
⏩ 129 skipped benchmarks1


Comparing swallace/loopback-service-binding-cohorts (87e1983) with main (ce52408)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@sohpeach
sohpeach force-pushed the swallace/loopback-service-binding-cohorts branch from 117d265 to d5a70e0 Compare February 24, 2026 15:21
Comment thread src/workerd/api/export-loopback.h Outdated
Comment thread src/workerd/api/export-loopback.h
@ask-bonk

ask-bonk Bot commented Feb 24, 2026 •

Copy link
Copy Markdown
Contributor

@sohpeach Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

@sohpeach
sohpeach force-pushed the swallace/loopback-service-binding-cohorts branch from d5a70e0 to 4fa1ce8 Compare February 24, 2026 18:30
@sohpeach

Copy link
Copy Markdown
Member Author

/bonk review

@ask-bonk

ask-bonk Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Review posted. Here's a summary of the findings:

Review Summary

I reviewed PR #6152 which adds a dynamic version (cohort) parameter to loopback service stubs.

Findings posted:

  1. [LOW] Unused include -- #include <workerd/io/features.h> in export-loopback.c++ is not used. Likely left over from an earlier iteration.

  2. [LOW] versionRequest silently ignored in server.c++ -- The new parameter is accepted but never read. A // TODO comment would help future readers understand this is intentional (the PR description explains it, but code outlives PR descriptions).

  3. [LOW] Test coverage is minimal -- The test confirms the new API shape doesn't crash, but doesn't verify version propagation. jp4a50's earlier feedback about also passing props and testing undefined appears unaddressed.

Non-issues confirmed:

  • jsg::Optional<kj::Maybe<kj::String>> cohort correctly models the JS undefined | null | string semantics
  • The two-method approach (call vs callWithVersion gated on compat flag) preserves backward compat
  • VersionRequest::clone() is correctly implemented
  • EW_EXPORT_LOOPBACK_ISOLATE_TYPES correctly includes the new struct types
  • TypeScript snapshots match the C++ definitions

Note: I was unable to post inline comments because the remote PR head appears to have been overwritten with a different commit. The overall review comment was posted successfully.


Time for a pun! I tried to review a cohort parameter, but it just kept versioning away from me.

github run

@jasnell

jasnell commented Feb 24, 2026

Copy link
Copy Markdown
Collaborator

Time for a pun! I tried to review a cohort parameter, but it just kept versioning away from me.

Ha!! Bonk picked up on the dad-jokes skill I added. Love it.

@sohpeach
sohpeach force-pushed the swallace/loopback-service-binding-cohorts branch 3 times, most recently from acc384a to bf03dd9 Compare February 25, 2026 18:25
Similar to `props`, this allows a worker to call the service stub as a
function, passing along the given version information (currently only a
cohort string) to the runtime.

workerd's server implementation currently ignores this information, so
the test included in this commit is very minimal. We could come up with
a better test once we've decided how this information will be exposed to
the worker, assuming it also makes sense in the workerd runtime. The
internal codebase tests this feature in more depth.

The feature is behind the experimental `enable_version_api` flag. Usage
looks like:
`let service = ctx.exports.default({ version: { cohort: "blah" } });`
@sohpeach
sohpeach force-pushed the swallace/loopback-service-binding-cohorts branch from bf03dd9 to 87e1983 Compare February 25, 2026 18:50
@sohpeach
sohpeach merged commit b0034e3 into main Feb 25, 2026
24 of 29 checks passed
@sohpeach
sohpeach deleted the swallace/loopback-service-binding-cohorts branch February 25, 2026 20:30
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.

3 participants