Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/curvy-showers-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/world-local": patch
---

Create a copy of the data when resolving a stream to rpevent detachment
2 changes: 1 addition & 1 deletion packages/world-local/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@workflow/world-local",
"version": "5.0.0-beta.10",
"version": "4.0.0-beta.10",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"version": "4.0.0-beta.10",
"version": "5.0.0-beta.11",

The package version was downgraded from 5.0.0-beta.10 to 4.0.0-beta.10, which is backwards and will cause version conflicts.

View Details

Analysis

Version downgrade in @workflow/world-local package

What fails: The version in packages/world-local/package.json was incorrectly downgraded from 5.0.0-beta.10 to 4.0.0-beta.10, violating semantic versioning and causing version conflicts with package managers.

How to reproduce:

# Check git history
git log --oneline -5 -- packages/world-local/package.json
# Commit ce4263e has version "4.0.0-beta.10" (incorrect)
# Commit 2856d66 has version "5.0.0-beta.10" (correct - previous version)

Result: Version downgraded from 5.0.0-beta.10 to 4.0.0-beta.10, which is a backward version change. The associated changeset specifies "patch" level changes but the version number went DOWN instead of UP.

Expected: Version should be 5.0.0-beta.11 (bumping the patch version from the previous beta.10), maintaining proper semver progression. Per semantic versioning, patch versions must increment monotonically within the same major and minor version.

Fixed: Version corrected to 5.0.0-beta.11 to maintain proper version ordering and consistency with the "patch" level changeset.

"description": "Local development World implementation for Workflow DevKit",
"type": "module",
"main": "dist/index.js",
Expand Down
56 changes: 56 additions & 0 deletions packages/world-local/src/streamer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,62 @@ describe('streamer', () => {

expect(chunks.join('')).toBe('123');
});

it('should read from stream starting at specified startIndex', async () => {
const { streamer } = await setupStreamer();
const streamName = 'startindex-stream';

// Write 5 chunks with delays to ensure different ULID timestamps
for (let i = 0; i < 5; i++) {
await streamer.writeToStream(streamName, TEST_RUN_ID, `${i}`);
await new Promise((resolve) => setTimeout(resolve, 2));
}
await streamer.closeStream(streamName, TEST_RUN_ID);

// Read from startIndex=2 (should get chunks 2, 3, 4)
const stream = await streamer.readFromStream(streamName, 2);
const reader = stream.getReader();

const chunks: string[] = [];
let done = false;

while (!done) {
const result = await reader.read();
done = result.done;
if (result.value) {
chunks.push(Buffer.from(result.value).toString());
}
}

expect(chunks.join('')).toBe('234');
});

it('should read from stream starting from first chunk with startIndex=0', async () => {
const { streamer } = await setupStreamer();
const streamName = 'startindex-zero-stream';

await streamer.writeToStream(streamName, TEST_RUN_ID, 'first');
await new Promise((resolve) => setTimeout(resolve, 2));
await streamer.writeToStream(streamName, TEST_RUN_ID, 'second');
await streamer.closeStream(streamName, TEST_RUN_ID);

// Read from startIndex=0 (should get all chunks)
const stream = await streamer.readFromStream(streamName, 0);
const reader = stream.getReader();

const chunks: string[] = [];
let done = false;

while (!done) {
const result = await reader.read();
done = result.done;
if (result.value) {
chunks.push(Buffer.from(result.value).toString());
}
}

expect(chunks.join('')).toBe('firstsecond');
});
});

describe('integration scenarios', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/world-local/src/streamer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ export function createStreamer(basedir: string): Streamer {
break;
}
if (chunk.chunk.byteLength) {
controller.enqueue(chunk.chunk);
process.stdout.write('.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
process.stdout.write('.');

Debug output code (process.stdout.write('.')) was accidentally left in the production fix and should be removed.

View Details

Analysis

Debug output code accidentally left in stream reader

What fails: The readFromStream() function in packages/world-local/src/streamer.ts (line 185) writes a debug dot character to stdout every time a chunk is enqueued during stream reading, polluting stdout with unwanted output.

How to reproduce: Create a stream with multiple chunks and read from it:

const streamer = createStreamer('./test-data');
const chunks = ['chunk1', 'chunk2', 'chunk3'];
for (const chunk of chunks) {
  await streamer.writeToStream('test-stream', Promise.resolve('run-1'), chunk);
}
await streamer.closeStream('test-stream', Promise.resolve('run-1'));

const stream = await streamer.readFromStream('test-stream');
const reader = stream.getReader();
while (true) {
  const { done } = await reader.read();
  if (done) break;
  // Observe: three dots printed to stdout (one per chunk)
}

Result: Three dots appear on stdout, one for each chunk enqueued

Expected: No debug output should appear on stdout. The function should silently enqueue chunks without printing to console.

Root cause: Commit d6b97db ("another fix") inadvertently added process.stdout.write('.'); at line 185, which should have been removed before commit. This was not mentioned in the commit message and is not part of the intended fix ("Create a copy of the data when resolving a stream to prevent detachment").

controller.enqueue(Uint8Array.prototype.slice.call(chunk.chunk));
}
}

Expand Down
Loading