Skip to content

Fix duplicate startup introspection requests#1539

Merged
sorenbs merged 2 commits into
mainfrom
codex/fix-initial-introspection-reset
Jul 14, 2026
Merged

Fix duplicate startup introspection requests#1539
sorenbs merged 2 commits into
mainfrom
codex/fix-initial-introspection-reset

Conversation

@sorenbs

@sorenbs sorenbs commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

  • avoid resetting a fresh query client when StudioContextProvider first mounts
  • retain cache invalidation when the adapter or database availability actually changes
  • document and test the single-introspection startup contract
  • add a minor changeset for @prisma/studio-core 0.33.0

Root cause

The database-configuration effect ran on the initial mount and called queryClient.resetQueries(). Child introspection queries had already started, so TanStack Query cancelled both BFF requests and immediately issued them again. Prisma ORM's Node server surfaced the cancelled response pipelines as ERR_STREAM_PREMATURE_CLOSE.

Validation

  • pnpm typecheck
  • pnpm lint (passes with existing repository warnings)
  • pnpm test:ui — 624 passed
  • pnpm test — 908 passed, 38 skipped
  • pnpm build
  • pnpm check:exports
  • pnpm changeset status — minor bump to 0.33.0
  • pnpm demo:ppg + Playwright at http://localhost:4310
    • initial introspection table and timezone requests each completed once with HTTP 200
    • no aborted startup requests or server errors
    • Migrations viewer loaded all 20 seeded Prisma Next migrations

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1c353e9d-c756-4a83-b909-6e76f645bcc3

📥 Commits

Reviewing files that changed from the base of the PR and between f7f1388 and c860f86.

📒 Files selected for processing (2)
  • .changeset/bright-dragons-introspect-once.md
  • ui/studio/context.test.tsx

Summary by CodeRabbit

  • Bug Fixes
    • Prevented duplicate/cancelled initial introspection requests when Studio mounts.
    • Improved schema discovery and cache refresh so data reloads only when adapter or database availability actually changes.
  • Tests
    • Added rerender-capable harness and assertions to verify introspection/caching behavior across initial load and config changes.
  • Documentation
    • Clarified live introspection timing in feature docs.
    • Expanded testing requirements to cover single initial introspection without mount-time cancellation/refetch.

Walkthrough

StudioContextProvider now remembers the previous adapter and database availability, skipping query-state reloads when both remain unchanged and resetting related state when either changes. Tests extend the render harness to rerender with updated configuration and verify cache-reset behavior. Architecture and feature documentation describe single initial discovery and reloads triggered by configuration changes, and a changeset records the minor release.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: preventing duplicate startup introspection requests.
Description check ✅ Passed The description is directly related to the code and tests, and it accurately summarizes the fix and validation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-initial-introspection-reset
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch codex/fix-initial-introspection-reset

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Compute preview deployed.

Branch: codex/fix-initial-introspection-reset
Service: codex-fix-initial-introspection-reset
Preview: https://r2d316nk4z1ywwclzpvnf0ld.cdg.prisma.build

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.changeset/bright-dragons-introspect-once.md:
- Line 5: Add a top-level Markdown heading to the changeset body after its
frontmatter so it satisfies markdownlint rule MD041, while preserving the
existing release-note text.

In `@ui/studio/context.test.tsx`:
- Around line 210-215: Update the rerender sequence in the adapter reset test
around resetQueriesSpy to rerender with the unchanged nextAdapter configuration
and assert the spy call count remains 1 before toggling hasDatabase. Keep the
existing assertion that changing hasDatabase increases the count to 2.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6256d8c3-601d-4ac2-99a9-af0f8e44d1ba

📥 Commits

Reviewing files that changed from the base of the PR and between e6cc33f and f7f1388.

📒 Files selected for processing (5)
  • .changeset/bright-dragons-introspect-once.md
  • Architecture/introspection.md
  • FEATURES.md
  • ui/studio/context.test.tsx
  • ui/studio/context.tsx

Comment thread .changeset/bright-dragons-introspect-once.md
Comment thread ui/studio/context.test.tsx
@sorenbs
sorenbs merged commit c341072 into main Jul 14, 2026
3 checks passed
@sorenbs
sorenbs deleted the codex/fix-initial-introspection-reset branch July 14, 2026 02:51
SevInf pushed a commit to prisma/prisma that referenced this pull request Jul 14, 2026
#29720)

## Summary

- update the bundled `@prisma/studio-core` from 0.27.3 to 0.33.0
- stop logging response-stream failures after the browser has already
disconnected
- handle the new optional `query-insights` BFF procedure with an
explicit unsupported response
- add regressions for disconnected clients and the expanded Studio BFF
contract

Studio Core 0.33.0 includes the Prisma Next Migrations viewer and the
duplicate startup-introspection fix from prisma/studio#1539.

## Validation

- `pnpm --dir packages/cli exec vitest run
src/__tests__/Studio.vitest.ts src/__tests__/studio-server.vitest.ts`
(19 passed)
- `pnpm --filter prisma build`
- `pnpm --filter prisma tsc`
- ESLint and Prettier checks for all touched files
- frozen offline lockfile install
- PostgreSQL 17 end-to-end run with two migrations applied by Prisma
Next: Studio listed both migrations, rendered schema deltas, and
displayed their SQL operations
- real delayed BFF request aborted by the client: no server error was
logged, and an immediate follow-up query succeeded

The broader CLI suite completed with 240 passing tests and three
`incomplete-schemas` Wasm snapshot failures caused by the local schema
engine returning `Schema engine error` instead of the expected P1013
detail. The same three failures reproduce on an unchanged `origin/main`
checkout.
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