Skip to content

fix(rivetkit): fix crypto dep in drizzle#4972

Merged
NathanFlurry merged 1 commit intomainfrom
05-05-fix_rivetkit_fix_crypto_dep_in_drizzle
May 5, 2026
Merged

fix(rivetkit): fix crypto dep in drizzle#4972
NathanFlurry merged 1 commit intomainfrom
05-05-fix_rivetkit_fix_crypto_dep_in_drizzle

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented May 5, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 5, 2026

PR Review: fix(rivetkit): fix crypto dep in drizzle

Overview

This PR replaces Node.js-specific crypto.createHash used in Drizzle migration hashing with the cross-platform Web Crypto API (globalThis.crypto.subtle), and adds the missing importNodeDependencies() call before getNodeFsSync() in the runtime static-dir path.

Correctness

  1. Hash compatibility: The old implementation used crypto.createHash with SHA-256 and UTF-8 encoding; the new implementation uses TextEncoder which is also UTF-8. This produces identical hex output, so existing __drizzle_migrations rows will not break on upgrade.

  2. importNodeDependencies placement: This fixes a pre-existing bug where getNodeFsSync() would throw because importNodeDependencies() was never called. The function guards on nodeFsSync !== undefined, so without the prior call it would fail at runtime.

  3. Async change: sha256Hex is now async while createHash was sync. The await is correctly propagated. ExecuteFunction accepts variadic ...args: unknown[] so the two-argument form (hash, entry.when) is correctly typed.

Issues and Suggestions

  1. Missing tests for sha256Hex: No unit test verifies known-vector output or that it matches the old createHash path. A test with a fixed input and expected SHA-256 hex string would provide a regression guard.

  2. Error message in sha256Hex guard could be more actionable: Consider adding context such as "available in Node >= 15, Bun, Deno, and modern browsers" so developers know what runtime upgrade is needed.

  3. Single importNodeDependencies call site: There is now only one call site in the codebase. Future Node-dependent paths added without it will fail at runtime rather than at startup, making the failure harder to diagnose.

Minor

sha256Hex has no comment explaining why Web Crypto was chosen over Node crypto. A brief inline note such as // Use Web Crypto for cross-runtime compatibility would help future contributors understand the intent.

Summary

The fix is correct. The main follow-up is a unit test for sha256Hex. The importNodeDependencies addition fixes a genuine pre-existing bug and is a welcome improvement.

@NathanFlurry NathanFlurry force-pushed the 05-05-fix_rivetkit_fix_crypto_dep_in_drizzle branch from 9c9be58 to fb15f93 Compare May 5, 2026 12:09
@NathanFlurry NathanFlurry force-pushed the depot-client/split-embedded-transport branch 2 times, most recently from f89fcba to c636bc6 Compare May 5, 2026 13:15
@NathanFlurry NathanFlurry force-pushed the 05-05-fix_rivetkit_fix_crypto_dep_in_drizzle branch from fb15f93 to 2a889fb Compare May 5, 2026 13:15
@NathanFlurry NathanFlurry marked this pull request as ready for review May 5, 2026 13:22
@NathanFlurry NathanFlurry force-pushed the 05-05-fix_rivetkit_fix_crypto_dep_in_drizzle branch from 2a889fb to 68707ac Compare May 5, 2026 13:40
@NathanFlurry NathanFlurry force-pushed the depot-client/split-embedded-transport branch from c636bc6 to 16bba5e Compare May 5, 2026 13:40
Base automatically changed from depot-client/split-embedded-transport to main May 5, 2026 14:58
@NathanFlurry NathanFlurry merged commit 68707ac into main May 5, 2026
26 of 38 checks passed
@NathanFlurry NathanFlurry deleted the 05-05-fix_rivetkit_fix_crypto_dep_in_drizzle branch May 5, 2026 14:58
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