Skip to content

Comments

fix: convert Buffer to Uint8Array for browser hydration compatibility#36

Open
boomyao wants to merge 1 commit intomizzle-dev:mainfrom
boomyao:fix/buffer-to-uint8array-hydration
Open

fix: convert Buffer to Uint8Array for browser hydration compatibility#36
boomyao wants to merge 1 commit intomizzle-dev:mainfrom
boomyao:fix/buffer-to-uint8array-hydration

Conversation

@boomyao
Copy link

@boomyao boomyao commented Feb 24, 2026

Summary

The workflow web inspect (>= 4.1.0-beta.56) now performs client-side hydration using hydrateData() from @workflow/core/serialization-format. This function checks for Uint8Array using instanceof, which fails for Buffer in the browser since Buffer doesn't exist in browser environments.

This fix ensures that MongoDB Binary data is converted to true Uint8Array before being returned, enabling proper data hydration in workflow web inspect.

Changes

  • Add bufferToUint8Array() helper function
  • Update stripUndefined() to convert Buffer/Binary to Uint8Array
  • Update cleanMongoDoc() to convert Buffer/Binary to Uint8Array
  • Update dependencies to latest workflow versions

Compatibility

  • workflow >= 4.1.0-beta.56: Required for web inspect to work properly
  • workflow < 4.1.0-beta.56: Backwards compatible - Uint8Array is a parent class of Buffer, so existing code continues to work

Testing

All 55 tests pass:

✓ test/spec.test.ts (5 tests)
✓ test/output-preservation.test.ts (14 tests)
✓ test/event-sourcing.test.ts (14 tests)
✓ test/serialization.test.ts (8 tests)
✓ test/hooks.test.ts (6 tests)
✓ test/streamer.test.ts (7 tests)

Signed-off-by: Assistant assistant@cursor.com

Made with Cursor

The workflow web inspect now performs client-side hydration using
hydrateData() from @workflow/core/serialization-format. This function
checks for Uint8Array using instanceof, which fails for Buffer in the
browser since Buffer doesn't exist in browser environments.

This fix ensures that MongoDB Binary data is converted to true Uint8Array
before being returned, enabling proper data hydration in workflow web inspect.

Changes:
- Add bufferToUint8Array() helper function
- Update stripUndefined() to convert Buffer/Binary to Uint8Array
- Update cleanMongoDoc() to convert Buffer/Binary to Uint8Array
- Update dependencies to latest workflow versions

Signed-off-by: Assistant <assistant@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@boomyao boomyao force-pushed the fix/buffer-to-uint8array-hydration branch from 97ff0ad to 3c3cdc9 Compare February 24, 2026 07:09
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