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

Error: ReferenceError: self is not defined when importing from npm module in Deno 1.45.3 #24726

Closed
nestarz opened this issue Jul 25, 2024 · 5 comments
Labels
bug Something isn't working correctly node compat

Comments

@nestarz
Copy link

nestarz commented Jul 25, 2024

I encountered an issue when upgrading from Deno 1.45.2 to 1.45.3. The following code throws an error in version 1.45.3, while it worked perfectly in 1.45.2.

Code

import "@sqlite.org/sqlite-wasm";

Error

error: Uncaught (in promise) ReferenceError: self is not defined
    at file:///node_modules/.deno/@sqlite.org+sqlite-wasm@3.46.0-build2/node_modules/@sqlite.org/sqlite-wasm/index.mjs:4:32

Steps to Reproduce

  1. Create a new Deno project.
  2. Add the following import statement in your code:
    import "@sqlite.org/sqlite-wasm";
  3. Run the project with Deno 1.45.3.

Expected Behavior

The import should work without any errors, as it did in Deno 1.45.2.

Actual Behavior

The import throws a ReferenceError: self is not defined.

Environment

  • Deno version: 1.45.3
  • @sqlite.org/sqlite-wasm version: 3.46.0-build2

Additional Information

Rolling back to Deno 1.45.2 resolves the issue, so it seems to be specific to the 1.45.3 release.

Please let me know if you need any additional information or if there are any workarounds for this issue. Thank you!

@nestarz nestarz changed the title Error: ReferenceError: self is not defined when importing @sqlite.org/sqlite-wasm in Deno 1.45.3 Error: ReferenceError: self is not defined when importing from npm module in Deno 1.45.3 Jul 25, 2024
@bartlomieju
Copy link
Member

bartlomieju commented Jul 25, 2024

Related #24683

CC @kt3k, maybe we should revert that change to remove self?

@bartlomieju bartlomieju added bug Something isn't working correctly node compat labels Jul 25, 2024
@bartlomieju
Copy link
Member

It appears that this package doesn't really target Node as per comments here: https://github.com/sqlite/sqlite-wasm/issues?q=is%3Aissue+self+is%3Aclosed.

That said, it's unfortunate that it will stop working and there's no workaround to it.

@dsherret @kt3k thoughts on this?

@nestarz
Copy link
Author

nestarz commented Jul 25, 2024

I published a forked version of the faulty package without the "self" reference :

https://www.npmjs.com/package/@eliaspourquoi/sqlite-node-wasm

It's a quick fix waiting for the owners to approve the merge of sqlite/sqlite-wasm#48.

@kt3k
Copy link
Member

kt3k commented Jul 26, 2024

I don't think we should revert #24637 as the snippet fails in Node.js with the exact same reason. I think this should be addressed in @sqlite.org/sqlite-wasm. (Also we can recommend the above fork for now.)

#24683 is not exactly the same issue. #24683 is about the descriptor of self in Deno mode. This issue is about unavailability of self in Node mode.

@lucacasonato
Copy link
Member

I'm goign to close this as this is not a bug in Deno, but in this package. Deno just happens to follow Node behaviour more closely, so the package that was previously working now fails (like on Node)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

No branches or pull requests

4 participants