Skip to content

Fix race condition in concurrent slidev export#2461

Merged
kermanx merged 5 commits into
slidevjs:mainfrom
moreal:fix-export-race-condition
Feb 24, 2026
Merged

Fix race condition in concurrent slidev export#2461
kermanx merged 5 commits into
slidevjs:mainfrom
moreal:fix-export-race-condition

Conversation

@moreal

@moreal moreal commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

Problem

slidev export runs a Vite server, then uses a headless browser to capture slides.
Under concurrent runs, the CLI could pass a candidate port to export logic instead of the actual bound port. If Vite moved to another port, the browser could connect to the wrong server.

In practice, one export command could render slides that belonged to another concurrent export target.
The error string below was from the regression test script, which detected that mismatch by checking output counts:

  • Unexpected PNG count in export-concurrency-b: expected 9, got 8

How to test

  1. Integration test (now in CI smoke workflow for all matrix entries):
node scripts/test-export-concurrency.mjs ../temp/slidev-project
  1. Stress loop (local repro helper):
bash scripts/test-export-concurrency-loop-until-failure.sh ../temp/slidev-project
# optional second arg: max runs

The integration test creates two decks (8 and 9 slides), runs two slidev export --format png processes in parallel, and verifies each output directory has the expected PNG count.

Fix

In slidev export and export-notes, resolve and use the actual Vite listening port instead of assuming the candidate port.

This prevents concurrent exports from rendering another command's slides and makes server cleanup deterministic.

@netlify

netlify Bot commented Feb 21, 2026

Copy link
Copy Markdown

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 8411c54
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/699d7e630647e00008db202a
😎 Deploy Preview https://deploy-preview-2461--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@moreal moreal changed the title Fix export race condition Fix race condition in concurrent slidev export Feb 21, 2026
@moreal
moreal marked this pull request as ready for review February 21, 2026 10:20
@antfu
antfu requested a review from kermanx February 24, 2026 09:47
@pkg-pr-new

pkg-pr-new Bot commented Feb 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2461

create-slidev

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@2461

create-slidev-theme

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2461

@slidev/parser

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2461

@slidev/cli

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2461

@slidev/types

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/types@2461

commit: 3bec383

@kermanx kermanx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the fix~

I removed the tests since they’re a bit hard to maintain.

@kermanx
kermanx merged commit 807caae into slidevjs:main Feb 24, 2026
3 of 4 checks passed
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.

2 participants