Skip to content

chore: maybe fix flaky - #6808

Merged
trpc-bot merged 2 commits into
mainfrom
06-04-eeek
Jun 4, 2025
Merged

trpc-bot merged 2 commits into
mainfrom
06-04-eeek

Conversation

@KATT

@KATT KATT commented Jun 4, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Chores
    • Improved test cleanup by automating resource management in test fixtures.
    • Removed automatic retry mechanism for failed tests in the test configuration.

@KATT
KATT requested a review from a team as a code owner June 4, 2025 15:46
@coderabbitai

coderabbitai Bot commented Jun 4, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This update refactors test cleanup in an optimistic update test to use a resource management pattern, replacing explicit cleanup calls. Additionally, it removes the test retry configuration from the Vitest setup, disabling automatic retries for failed tests. No changes are made to exported or public entity declarations.

Changes

File(s) Change Summary
packages/upgrade/test/fixtures/hooks/optimistic-update.spec.tsx Refactored test cleanup to use makeResource for automatic cleanup.
packages/upgrade/vitest.config.ts Removed retry: 10 from Vitest test configuration.

Possibly related PRs

  • trpc/trpc#6783: Adjusts the same Vitest retry configuration, but in the opposite direction by adding the retry mechanism.

Poem

In the warren where tests hop and play,
Cleanup now happens the resourceful way.
No more retries, just one honest run—
When the test is done, the cleanup’s begun.
A hop, a skip, a code refactor delight,
The rabbits rejoice: all is tidy and right! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40dbd7e and 95aac95.

📒 Files selected for processing (2)
  • packages/upgrade/test/__fixtures__/hooks/optimistic-update.spec.tsx (2 hunks)
  • packages/upgrade/vitest.config.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/upgrade/vitest.config.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/upgrade/test/__fixtures__/hooks/optimistic-update.spec.tsx (2)
packages/server/src/unstable-core-do-not-import/stream/utils/disposable.ts (1)
  • makeResource (16-29)
packages/upgrade/test/__fixtures__/hooks/optimistic-update.trpc.tsx (1)
  • resetFixtureState (26-28)
⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: E2E-tests (nuxt)
  • GitHub Check: E2E-tests (tanstack-start)
  • GitHub Check: E2E-tests (next-prisma-starter)
  • GitHub Check: E2E-tests (fastify-server)
  • GitHub Check: E2E-tests (express-minimal)
  • GitHub Check: E2E-tests (.test/internal-types-export)
  • GitHub Check: E2E-tests (.experimental/next-app-dir)
  • GitHub Check: E2E-tests (.test/ssg)
  • GitHub Check: e2e-legacy-node (next-prisma-todomvc, 20.x)
  • GitHub Check: e2e-legacy-node (next-prisma-todomvc, 18.x)
  • GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 20.x)
  • GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 18.x)
  • GitHub Check: e2e-legacy-node (next-prisma-starter, 20.x)
  • GitHub Check: e2e-legacy-node (next-prisma-starter, 18.x)
  • GitHub Check: Test a monorepo using built declaration files
  • GitHub Check: E2E-tests (Bun) (bun, ubuntu-latest)
  • GitHub Check: E2E-tests (Deno) (deno-deploy)
  • GitHub Check: Analyze (typescript)
  • GitHub Check: test
🔇 Additional comments (2)
packages/upgrade/test/__fixtures__/hooks/optimistic-update.spec.tsx (2)

2-2: LGTM: Import addition for resource management pattern.

The import of makeResource from the tRPC unstable core is appropriate for implementing the cleanup refactoring.


11-14:

Details

❓ Verification inconclusive

Excellent refactoring to use explicit resource management for test cleanup.

This change replaces explicit cleanup calls with the JavaScript using declaration, ensuring that resetFixtureState() and utils.unmount() are automatically called when the scope exits, regardless of whether the test succeeds or throws an exception. This should help prevent test state leakage and reduce flakiness.

The resource management pattern is particularly valuable for test cleanup because:

  • Guarantees cleanup execution even if assertions fail
  • Prevents fixture state pollution between test runs
  • Makes cleanup intent more declarative

Please verify that your test environment supports the using declaration syntax:


🌐 Web query:

Does Node.js and modern JavaScript test environments support the "using" declaration for explicit resource management?

💡 Result:

Support for the using Declaration in Node.js and JavaScript Test Environments

Summary:
Node.js and modern JavaScript test environments are beginning to support the using declaration for explicit resource management, based on the latest ECMAScript proposals and TypeScript advancements. However, support depends on your runtime version and tooling configuration.


What is the using Declaration?

The using declaration is an upcoming ECMAScript feature designed for explicit resource management. It allows you to declare resources—such as file handles or database connections—in a way that ensures cleanup code (typically defined by a Symbol.dispose method) is automatically called at the end of the scope, without manual try...finally blocks. This pattern is comparable to C#'s using, Python's with, or Java's try-with-resources[3][6].

Example:

using file = new TempFile("my_temp.txt");
// use file...
// `file[Symbol.dispose]()` will be called automatically at scope end

Current State of Support

Node.js

  • Native JavaScript support for the using declaration relies on the ECMAScript Explicit Resource Management proposal, which is making its way through the standardization process.
  • As of 2025, this proposal is not yet finalized in all JavaScript engines, and as a result, Node.js may or may not natively support it out-of-the-box, depending on your exact Node.js version and the status of ECMAScript feature flags at runtime.

TypeScript

  • TypeScript 5.2 and newer provide support for the using declaration, under the assumption that the underlying JavaScript engine implements (or will soon implement) the feature[3][6]. This allows developers to use the syntax in TypeScript projects now, with TypeScript transpiling (or polyfilling) as necessary for compatibility[3][6].

Test Frameworks (e.g., Mocha, Jest, etc.)

  • Test environments running on Node.js will generally inherit the JavaScript (or TypeScript, if used) features available in the current runtime.
  • Thus, the ability to use using in your tests depends on whether your test runner executes code in a Node.js version and configuration that supports this proposal, or if you're using TypeScript 5.2+ along with the correct configuration.

Practical Guidance and Caveats

  • If you are using TypeScript 5.2 or later, you can start using using declarations for resource management today, provided your build process targets an environment with support for the feature, or transpiles to compatible code[3][6].
  • If you are writing vanilla JavaScript in Node.js, full support for using will depend on your Node.js version and whether the feature is enabled or polyfilled. Check your runtime documentation for the latest status.
  • In test environments, the ability to use using is tied to your language/toolchain, not the test framework itself (e.g., Mocha, Jest), assuming these are run in a recent Node.js version or with TypeScript transpilation.

Key References

TypeScript 5.2 adds support for the upcoming Explicit Resource Management feature in ECMAScript.... using is a new keyword that lets us declare new fixed bindings, kind of like const. The key difference is that variables declared with using get their Symbol.dispose method called at the end of the scope![3][6].

...as of 22 August 2023, it’s currently available in the new TypeScript 5.2, so you should be able to use it today, as long as you update your installed version of TypeScript![6].


In summary: Modern JavaScript (especially with TypeScript 5.2+) and Node.js are actively introducing support for using declarations and explicit resource management, but ensure your environment is up-to-date and properly configured to take advantage of this feature[3][6].

Citations:


Please confirm runtime and tooling support for using declarations

Excellent refactoring to use explicit resource management for test cleanup. By replacing manual calls to resetFixtureState() and utils.unmount() with a using declaration, you ensure cleanup always runs at scope exit—even on test failures—making cleanup intent more declarative and preventing fixture pollution.

Before merging, verify that your test environment is configured to support the ECMAScript “Explicit Resource Management” proposal:

  • Node.js:
    • Upgrade to v24+ which includes the feature natively, or
    • Run with the --harmony-explicit-resource-management flag if it’s still experimental in your version
  • TypeScript (if used):
    • Ensure you’re on TS 5.2+
    • Set "target": "esnext" (or higher) in tsconfig.json so using isn’t down-leveled into unsupported syntax
  • Test runner (Jest, Mocha, etc.):
    • Confirm it executes code through the Node.js runtime or TS compiler that supports using
    • Add any necessary flags or polyfills in your CI/test scripts

Once you’ve validated these settings, you can safely approve this change.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel

vercel Bot commented Jun 4, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-prisma-starter ✅ Ready (Inspect) Visit Preview Jun 4, 2025 3:51pm
og-image ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2025 3:51pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2025 3:51pm

@trpc-bot
trpc-bot enabled auto-merge (squash) June 4, 2025 15:48
@railway-app
railway-app Bot temporarily deployed to trpc-pr-6808 June 4, 2025 15:49 Destroyed
@railway-app

railway-app Bot commented Jun 4, 2025 •

Copy link
Copy Markdown

🚅 Deployed to the trpc-pr-6808 environment in trpc-sse-and-websockets

Service Status Web Updated (UTC)
next-sse-chat ◻️ Removed (View Logs) Web Jun 4, 2025 at 3:55 pm

@pkg-pr-new

pkg-pr-new Bot commented Jun 4, 2025

Copy link
Copy Markdown

Open in StackBlitz

@trpc/client

npm i https://pkg.pr.new/trpc/trpc/@trpc/client@6808

@trpc/next

npm i https://pkg.pr.new/trpc/trpc/@trpc/next@6808

@trpc/react-query

npm i https://pkg.pr.new/trpc/trpc/@trpc/react-query@6808

@trpc/server

npm i https://pkg.pr.new/trpc/trpc/@trpc/server@6808

@trpc/tanstack-react-query

npm i https://pkg.pr.new/trpc/trpc/@trpc/tanstack-react-query@6808

@trpc/upgrade

npm i https://pkg.pr.new/trpc/trpc/@trpc/upgrade@6808

commit: c1cad10

@trpc-bot
trpc-bot merged commit 46afe65 into main Jun 4, 2025
@trpc-bot
trpc-bot deleted the 06-04-eeek branch June 4, 2025 15:55
@github-actions

github-actions Bot commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 6, 2025

This branch was successfully deployed

5 active deployments
Preview – www — c1cad102 Deployed Jun 4, 2025 by vercel[bot]
Preview – examples-todomvc — c1cad102 Deployed Jun 4, 2025 by vercel[bot]
Preview – og-image — c1cad102 Deployed Jun 4, 2025 by vercel[bot]
Preview – next-prisma-starter — c1cad102 Deployed Jun 4, 2025 by vercel[bot]
Preview – trpc-next-app-dir — c1cad102 Deployed Jun 4, 2025 by vercel[bot]
trpc-pr-6808 — c1cad102 Deployed Jun 4, 2025 by railway-app[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants