Skip to content

[vitest-plugin] Declare the adminSecretsStore() result as disposable - #15706

Merged
cjol merged 5 commits into
cloudflare:mainfrom
Om-singhaI:fix/vitest-plugin-dispose-secrets-admin
Sep 22, 2026
Merged

cjol merged 5 commits into
cloudflare:mainfrom
Om-singhaI:fix/vitest-plugin-dispose-secrets-admin

Conversation

@Om-singhaI

@Om-singhaI Om-singhaI commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #15696.

adminSecretsStore() returns the RPC promise from the binding's admin API, which workerd makes disposable. But the SecretsStoreSecretAdmin type in cloudflare:test left out Symbol.dispose, and the JSDoc example assigned the result with const. So a test that followed the example leaked the stubs until the garbage collector ran, and workerd printed "An RPC stub was not disposed properly". The issue has a deterministic reproduction and shows that using on the result removes the warning.

This declares [Symbol.dispose](): void on SecretsStoreSecretAdmin, the same way WorkflowInstanceIntrospector already declares [Symbol.asyncDispose], and changes both examples to using admin = adminSecretsStore(env.MY_SECRET). There's no runtime change.

test/types.test.ts now compiles a using declaration of the result. With the previous cloudflare-test.d.ts it fails with TS2850, since the initializer of a using declaration needs a [Symbol.dispose]() method. With this change it passes. oxfmt and oxlint are clean on the changed files.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: adminSecretsStore() is only documented in the cloudflare:test type declarations, which this updates.

Devin Review

The admin API is backed by RPC stubs, and both the returned promise and the
object it resolves to carry Symbol.dispose, but SecretsStoreSecretAdmin left it
out and the example assigned the result with const. A test that followed the
example leaked the stubs until the garbage collector ran, and workerd warned
that an RPC stub was not disposed properly.

Declare the disposer on the interface, the way WorkflowInstanceIntrospector
declares Symbol.asyncDispose, show using in both examples, and pin it in the
types test.
@changeset-bot

changeset-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f4dcf0d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vitest-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Sep 18, 2026
@workers-devprod
workers-devprod requested review from a team and cjol and removed request for a team September 18, 2026 07:20
@workers-devprod

workers-devprod commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

The seeded integration test still assigned the adminSecretsStore() result
with const, so disposal only ever ran through the types test. Declaring it
with using makes the runtime test follow the documented example, and using
throws at the start of the scope if the value is not disposable.
@pkg-pr-new

pkg-pr-new Bot commented Sep 18, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15706

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15706

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15706

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15706

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@15706

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15706

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15706

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15706

miniflare

npm i https://pkg.pr.new/miniflare@15706

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15706

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15706

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15706

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15706

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15706

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15706

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15706

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15706

wrangler

npm i https://pkg.pr.new/wrangler@15706

commit: f4dcf0d

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Sep 22, 2026
@cjol
cjol enabled auto-merge (squash) September 22, 2026 16:25
@cjol
cjol merged commit f5341a4 into cloudflare:main Sep 22, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

vitest-plugin: adminSecretsStore() returns an RPC stub that its type and example never dispose, so workerd warns "An RPC stub was not disposed properly"

3 participants