Skip to content

Avoid timers in synchronous scheduler dispatch - #6657

Merged
tim-smart merged 1 commit into
mainfrom
agent/codex-engineer/929fc999
Jul 27, 2026
Merged

Avoid timers in synchronous scheduler dispatch#6657
tim-smart merged 1 commit into
mainfrom
agent/codex-engineer/929fc999

Conversation

@tim-smart

@tim-smart tim-smart commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • dispatch yielded sync-mode scheduler work with cancellable microtasks when no custom dispatcher is supplied
  • run Standard Schema validation with a sync-mode scheduler
  • cover Convex-like environments where timer APIs throw and add a patch changeset

Testing

  • pnpm lint-fix
  • pnpm check
  • pnpm --filter effect test --run (232 files passed; 7,162 tests passed; 3 skipped)

Closes EFF-115
Closes EFF-113
Closes #6651

Summary by CodeRabbit

  • Bug Fixes
    • Synchronous effect execution now dispatches yielded work through cancellable microtasks.
    • Synchronous schema validation uses the updated scheduling behavior.
    • Avoids unnecessary timer-based scheduling during synchronous runs.

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 27, 2026
@changeset-bot

changeset-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: afae057

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

This PR includes changesets to release 28 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/openapi-generator 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

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a1e1c4b8-3e0c-4527-a56f-51224361adf0

📥 Commits

Reviewing files that changed from the base of the PR and between 3fccb56 and afae057.

📒 Files selected for processing (4)
  • .changeset/eff-115-sync-scheduler-microtask.md
  • packages/effect/src/Scheduler.ts
  • packages/effect/src/Schema.ts
  • packages/effect/test/Scheduler.test.ts

📝 Walkthrough

Walkthrough

Synchronous scheduler dispatch now uses cancellable microtasks instead of timer-based scheduling. Standard Schema validation opts into sync mode, and tests verify yielded synchronous effects complete without calling timer APIs.

Changes

Sync scheduler dispatch

Layer / File(s) Summary
Cancellable synchronous dispatch
packages/effect/src/Scheduler.ts
Adds cancellable queueMicrotask scheduling and makes MixedScheduler select it by default for "sync" execution while retaining the existing async scheduler fallback.
Schema integration and regression coverage
packages/effect/src/Schema.ts, packages/effect/test/Scheduler.test.ts, .changeset/eff-115-sync-scheduler-microtask.md
Standard Schema validation constructs a sync scheduler; tests verify yielded synchronous effects avoid setImmediate and setTimeout, and a patch changeset documents the update.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: bug, 4.0

Suggested reviewers: gcanti

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements sync-mode microtask dispatch and switches Standard Schema validation to it, matching the issue’s requirement to avoid timer APIs in synchronous paths.
Out of Scope Changes check ✅ Passed All changes are directly tied to the sync scheduler fix, validation path update, test coverage, and release note.

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

@coderabbitai coderabbitai Bot added 4.0 bug Something isn't working labels Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.63 KB 6.60 KB +0.03 KB (+0.50%)
batching.ts 9.37 KB 9.34 KB +0.04 KB (+0.37%)
brand.ts 6.25 KB 6.25 KB 0.00 KB (0.00%)
cache.ts 10.11 KB 10.07 KB +0.04 KB (+0.39%)
config.ts 19.21 KB 19.17 KB +0.04 KB (+0.23%)
differ.ts 18.42 KB 18.39 KB +0.03 KB (+0.14%)
http-client.ts 20.76 KB 20.73 KB +0.03 KB (+0.15%)
logger.ts 10.28 KB 10.25 KB +0.04 KB (+0.35%)
metric.ts 8.55 KB 8.51 KB +0.04 KB (+0.47%)
optic.ts 7.41 KB 7.41 KB 0.00 KB (0.00%)
pubsub.ts 14.19 KB 14.16 KB +0.04 KB (+0.25%)
queue.ts 11.08 KB 11.05 KB +0.03 KB (+0.31%)
schedule.ts 10.27 KB 10.24 KB +0.04 KB (+0.37%)
schema-class.ts 18.16 KB 18.12 KB +0.04 KB (+0.22%)
schema-fromJsonSchemaDocument.ts 28.02 KB 27.97 KB +0.05 KB (+0.17%)
schema-representation-roundtrip.ts 24.33 KB 24.30 KB +0.03 KB (+0.13%)
schema-string-transformation.ts 12.69 KB 12.65 KB +0.04 KB (+0.29%)
schema-string.ts 10.35 KB 10.31 KB +0.04 KB (+0.37%)
schema-template-literal.ts 14.48 KB 14.45 KB +0.04 KB (+0.24%)
schema-toArbitraryLazy.ts 20.93 KB 20.90 KB +0.03 KB (+0.16%)
schema-toCodeDocument.ts 23.38 KB 23.33 KB +0.05 KB (+0.20%)
schema-toCodecJson.ts 18.32 KB 18.29 KB +0.03 KB (+0.15%)
schema-toEquivalence.ts 18.00 KB 17.96 KB +0.04 KB (+0.21%)
schema-toFormatter.ts 17.88 KB 17.84 KB +0.04 KB (+0.21%)
schema-toJsonSchemaDocument.ts 21.51 KB 21.48 KB +0.03 KB (+0.15%)
schema-toRepresentation.ts 18.55 KB 18.52 KB +0.03 KB (+0.15%)
schema.ts 17.43 KB 17.39 KB +0.03 KB (+0.20%)
stm.ts 12.05 KB 12.02 KB +0.03 KB (+0.28%)
stream.ts 9.36 KB 9.32 KB +0.04 KB (+0.45%)

@tim-smart
tim-smart merged commit 205ebc7 into main Jul 27, 2026
15 checks passed
@tim-smart
tim-smart deleted the agent/codex-engineer/929fc999 branch July 27, 2026 03:23
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Done in PR Backlog Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Effect.runSync arms an unused timer and so fails in Convex's isolate

1 participant