Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeMismatchError when using Node 17.6 #188

Closed
vlovich opened this issue Feb 25, 2022 · 2 comments
Closed

TypeMismatchError when using Node 17.6 #188

vlovich opened this issue Feb 25, 2022 · 2 comments
Milestone

Comments

@vlovich
Copy link
Contributor

vlovich commented Feb 25, 2022

Today I used patch-package to patch @miniflare/durable-objects@2.3.0 for the project I'm working on.

Invoking newUniqueId throws a TypeMismatchError. Replacing the DataView with Uint8Array fixes the issue.

Here is the diff that solved my problem:

diff --git a/node_modules/@miniflare/durable-objects/dist/src/index.js b/node_modules/@miniflare/durable-objects/dist/src/index.js
index 692dd6d..9d3c92a 100644
--- a/node_modules/@miniflare/durable-objects/dist/src/index.js
+++ b/node_modules/@miniflare/durable-objects/dist/src/index.js
@@ -159,7 +159,7 @@ var DurableObjectNamespace = class {
     const id = new Uint8Array(32);
     const view = new DataView(id.buffer);
     view.setBigUint64(1, BigInt(Date.now()));
-    import_crypto.webcrypto.getRandomValues(new DataView(id.buffer, 9, 15));
+    import_crypto.webcrypto.getRandomValues(new Uint8Array(id.buffer, 9, 15));
     id.set(this.#objectNameHash, 24);
     return new DurableObjectId(this.#objectName, hexEncode(id));
   }

This issue body was partially generated by patch-package.

@vlovich
Copy link
Contributor Author

vlovich commented Mar 1, 2022

Fixed in b887877

@vlovich vlovich closed this as completed Mar 1, 2022
@mrbbot mrbbot added this to the 2.4.0 milestone Mar 8, 2022
@mrbbot
Copy link
Contributor

mrbbot commented Apr 2, 2022

Hey! 👋 I've just released version 2.4.0 including the fix for this. You can find the full changelog here.

adamalton added a commit to web3-storage/web3.storage that referenced this issue May 11, 2022
This gets us the fix to this: cloudflare/miniflare#188 which is current breaking all tests on the CI.
adamalton added a commit to web3-storage/web3.storage that referenced this issue May 11, 2022
This gets us the fix to this: cloudflare/miniflare#188 which is current breaking all tests on the CI.
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

No branches or pull requests

2 participants