Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

node errors in Trace.ts #1067

Closed
ryanleecode opened this issue Jun 13, 2023 · 0 comments · Fixed by #1071
Closed

node errors in Trace.ts #1067

ryanleecode opened this issue Jun 13, 2023 · 0 comments · Fixed by #1071
Assignees

Comments

@ryanleecode
Copy link
Contributor

ryanleecode commented Jun 13, 2023

Likely introduced in #1062

Failed (7/37) "target/npm/capi-examples/esm/examples/tx/balances_transfer.eg.js"
file:///home/runner/work/capi/capi/target/npm/capi-examples/node_modules/capi/esm/rune/Trace.js:65
    globalThis.addEventListener("error", (e) => {
               ^

TypeError: globalThis.addEventListener is not a function
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Suggested fix:

diff --git a/deps/shims/Deno.node.ts b/deps/shims/Deno.node.ts
index 2a66799..501c093 100644
--- a/deps/shims/Deno.node.ts
+++ b/deps/shims/Deno.node.ts
@@ -3,6 +3,7 @@ import { Command } from "./command.node.ts"
 
 declare const process: { env: Record<string, string> }
 let _deno = {
+  isShim: true,
   errors: {
     NotFound: class NotFound extends Error {},
     AlreadyExists: class AlreadyExists extends Error {},
diff --git a/rune/Trace.ts b/rune/Trace.ts
index 8786ecd..2fe2168 100644
--- a/rune/Trace.ts
+++ b/rune/Trace.ts
@@ -70,7 +70,7 @@ Error.prepareStackTrace = (err, sites) => {
 }
 
 // Force deno to use the custom prepareStackTrace when an error isn't handled
-if ("Deno" in globalThis) {
+if ("Deno" in globalThis && !("isShim" in globalThis["Deno"])) {
   globalThis.addEventListener("error", (e) => {
     handler(e.error)
   })

After applying patch there is new error

Failed (34/37) "target/npm/capi-examples/esm/examples/misc/indices.eg.js"
file:///home/ryan/Documents/Repositories/capi/target/npm/capi-examples/node_modules/capi/esm/rune/Trace.js:163
        if (site.functionName()) {
                 ^

TypeError: site.functionName is not a function
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js v20.1.0
@robocapi robocapi added this to Capi Jun 13, 2023
@ryanleecode ryanleecode changed the title node errors in Trace.ts node errors in Trace.ts Jun 13, 2023
@tjjfvi tjjfvi mentioned this issue Jun 14, 2023
@github-project-automation github-project-automation bot moved this to Done in Capi Jun 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants