Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 22, 2025

The local world implementation had several bugs related to stream handling and lacked documentation about its concurrency limitations.

Changes

Streamer fixes:

  • Fixed empty chunk inconsistency: chunks with byteLength === 0 are now skipped in event listeners to match disk reading behavior
  • Fixed unreachable type check in writeToStream where string-to-Uint8Array conversion made subsequent string check impossible
// Before: chunk reassigned, making type check unreachable
if (typeof chunk === 'string') {
  chunk = new TextEncoder().encode(chunk);
}
// Later: this check never true
const chunkData = typeof chunk === 'string' ? ... : chunk;

// After: separate variable for clarity
let chunkBuffer: Buffer;
if (typeof chunk === 'string') {
  chunkBuffer = Buffer.from(new TextEncoder().encode(chunk));
}

Filesystem robustness:

  • Track temp file creation before cleanup attempt in write() function

Documentation:

  • Added JSDoc explaining last-writer-wins semantics for concurrent updates in filesystem-based storage
  • Documented limitations in write(), runs.update(), and steps.update()

All existing tests pass (124/124).

Original prompt

The local world seems to be quite buggy, especially when dealing with multiple writers and streams. Look through the code of the local world and identify some potential bugs that need to be fixed


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot
Copy link

changeset-bot bot commented Nov 22, 2025

🦋 Changeset detected

Latest commit: b4f8bb1

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

This PR includes changesets to release 13 packages
Name Type
@workflow/core Patch
@workflow/world-local Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/web-shared Patch
workflow Patch
@workflow/world-postgres Patch
@workflow/sveltekit Patch
@workflow/world-testing Patch
@workflow/nuxt Patch
@workflow/ai 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

@vercel
Copy link
Contributor

vercel bot commented Nov 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Comment Nov 22, 2025 7:46am
example-nextjs-workflow-webpack Ready Ready Preview Comment Nov 22, 2025 7:46am
example-workflow Ready Ready Preview Comment Nov 22, 2025 7:46am
workbench-astro-workflow Error Error Nov 22, 2025 7:46am
workbench-express-workflow Ready Ready Preview Comment Nov 22, 2025 7:46am
workbench-hono-workflow Ready Ready Preview Comment Nov 22, 2025 7:46am
workbench-nitro-workflow Ready Ready Preview Comment Nov 22, 2025 7:46am
workbench-nuxt-workflow Ready Ready Preview Comment Nov 22, 2025 7:46am
workbench-sveltekit-workflow Ready Ready Preview Comment Nov 22, 2025 7:46am
workbench-vite-workflow Ready Ready Preview Comment Nov 22, 2025 7:46am
workflow-docs Ready Ready Preview Comment Nov 22, 2025 7:46am

…entation

Co-authored-by: pranaygp <1797812+pranaygp@users.noreply.github.com>
Co-authored-by: pranaygp <1797812+pranaygp@users.noreply.github.com>
@pranaygp pranaygp merged commit 3436629 into main Nov 22, 2025
42 of 54 checks passed
@pranaygp pranaygp deleted the copilot/fix-local-world-bugs branch November 22, 2025 15:26
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