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
Cannot find module 'atob' #768
Comments
@Clee681 Thanks for posting! I will ask our SDK engineers to take a look and comment. |
I confirm the issue when importing 5.0.2. Here is a PR to fix this: #786 |
@Clee681 Thanks for reporting the issue, we will release a patch for it and get you updated in this thread. @hirako2000 Thanks for your contribution! As there still are some other missing modules in Internal Ref: OKTA-402553 |
@shuowu-okta we are getting a similar issue: Will this be included in the patch? |
@jchabotamica Yep, you can check #805 for details. |
One workaround before the patch release is to manually add modules |
Thanks @shuowu-okta!! |
Patches released. You can find 5.1.1 and 5.0.3 on npm. |
@shuowu-okta I'm seeing the below error on fresh install
|
@Clee681 Which version of okta-auth-js are you using? Also, looks like you are using the CommonJS bundle(cjs), are you working on a server side app? |
@shuowu-okta I'm using |
@shuowu-okta Any ideas if this is an esm vs. cjs issue in |
@shuowu-okta I was able to track my issue down to the |
@Clee681 This module is used as a fallback for node env, browser side depends on the Web_Crypto_API. So your app is doing server side rendering, and the bundler picked the cjs bundle of okta-auth-js, then in which step you see the error above? |
@shuowu-okta Gotcha. I created a quick bare bones reproduction here https://github.com/Clee681/okta-esm-module-repro. Steps to view the error:
I only added one line to the base template which was the below: I appreciate you responding so quickly! |
@Clee681 I think this issue happens when Also another work can be using the okta-auth-js artifact from Okta global CDN ( v5.1.1 ) to avoid the bundler issue. |
Thanks for looking into it. I'll try bypassing any optimization via the Vite config options to see if that fixes the issue in the repro project. On first thought, I'm wondering if that solution will work for my SvelteKit app though. Based on my current implementation, I use |
@shuowu-okta I think I finally identified the issue. Vite doesn't seem to like how I have a thread in their repository so will report back what they say. I suspect this will be a bigger issue as Vite is gaining a lot of traction in the React, Vue, and Svelte worlds. |
@Clee681 Instead of fighting against I am not very familiar with |
Interesting, thank you. I'll try that to at least unblock my current work. Will still keep up with the |
@Clee681 Close this issue as it appears to be an issue in vite. Feel free to reopen it if you have any further questions. |
Please reopen. It is not an issue with vite. I reproduced the issue with zero frameworks. Just importing okta-auth-js causes the problem. Also to note, this issue is specifically for the atob dependency being missing. While I appreciate there are problems with dependencies as well, and that the internal team would like to fix them all, those are of different nature and would better be patched separately. A PR was created to patch this issue specifically but it has now be ignored in favour of fixing the problem as part of another code merge. It is not an easy to track process and in a way contradicts the nature of allowing the community at wide to offer pull request. I hope you understand my concern, which now goes beyond the fact a release of this library totally broke any dependent project using it.
You actually have a nice CI integration, and some unit tests in place. I'm willing to review the unit tests and add the necessary cases to strengthen the validation so that if an issue with dependencies occur in the future, you CI catches it. Edit: The patch works. don't revert anything. |
@Clee681, while @shuowu's suggestion may work around your problen, vite is designed to handle dependencies to provide many of its benefit. If vite has an issue with building certain assets, file an issue with vite and mention it in this thread so that others who are affected can make sense of that's going on. (which you did) The vite team is very active and will promptly provide feedback if indeed vite is at faullt :) |
I've tested 5.1.1 and the atom dependencies is imported fine. Thanks for fixing it. The other issues are another problem impacting certain configuration of Vite or the way the deps are imported. My comment about the release and merging process still applies though. I do hope it is taken in consideration for future handling so that users who track issues don't have to second guess and jump on other related issues to make sense of the fix. package.json: {
"name": "test-okta",
"version": "1.0.0",
"description": "just a test of loading okta-auth-js",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "hirako2000",
"license": "MIT",
"dependencies": {
"@okta/okta-auth-js": "^5.1.1"
}
} index.js: require('@okta/okta-auth-js');
console.log('loading okta-auth-js OK'); Execution: $ node index.js # node v14.x
> loading okta-auth-js OK While when reproducing the same with v5.0.2, the load was failing: $ node index.js
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'atob'
Require stack:
- ../test-okta/node_modules/@okta/okta-auth-js/cjs/crypto/node.js
- ../test-okta/node_modules/@okta/okta-auth-js/cjs/crypto/webcrypto.js
- ../test-okta/node_modules/@okta/okta-auth-js/cjs/crypto/base64.js
- ../test-okta/node_modules/@okta/okta-auth-js/cjs/crypto/index.js
- ../test-okta/node_modules/@okta/okta-auth-js/cjs/oidc/util/pkce.js
- ../test-okta/node_modules/@okta/okta-auth-js/cjs/OktaAuth.js
- ../test-okta/node_modules/@okta/okta-auth-js/cjs/index.js
- ../test-okta/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (../test-okta/node_modules/@okta/okta-auth-js/cjs/crypto/node.js:14:22)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'../test-okta/node_modules/@okta/okta-auth-js/cjs/crypto/node.js',
'../test-okta/node_modules/@okta/okta-auth-js/cjs/crypto/webcrypto.js',
'../test-okta/node_modules/@okta/okta-auth-js/cjs/crypto/base64.js',
'../test-okta/node_modules/@okta/okta-auth-js/cjs/crypto/index.js',
'../test-okta/node_modules/@okta/okta-auth-js/cjs/oidc/util/pkce.js',
'../test-okta/node_modules/@okta/okta-auth-js/cjs/OktaAuth.js',
'../test-okta/node_modules/@okta/okta-auth-js/cjs/index.js',
'../test-okta/index.js'
]
} So the patch works. thanks. Note how a simple test run by CI would catch dependencies run time issues going forward. |
@hirako2000 Thanks for all the suggestion about how to improve the CI! We are actually also exploring approachs to protect against issues like this and it's tracked with an internal Jira. To be more specific, we currently do run a test harness app which loads the latest okta-auth-js package in CI, but due to the nature of |
Hello,
When importing
OktaAuth
from5.0.2
using nodev14.15.0
, I get the following module error.Edit: Confirmed that this is not an issue in
4.9.2
The text was updated successfully, but these errors were encountered: