Signing back into the Community for the first time? You'll need to reset your password to access your account. Find out more.
Forum Discussion
JamieRI
3 days agoNew Contributor
crypto.randomUUID is not a function S @ inject-content-scripts.js:5
FYI: I bumped into an error associated with 1Password Beta extension 8.10.56.22 when I was inspecting a site for an unrelated reason. This is not impacting me, just thought you might like to know.
Site is http://atecconnectors.com/atec/index.cfm
Chrome Dev console says
"inject-content-scripts.js:5 Failed to fetch chrome-extension://khgocmkkpikpnmmkgmdnfckapcdkgfaf/inline/injected.js, Import failed 3 times. Final error: crypto.randomUUID is not a function
S @ inject-content-scripts.js:5"
The DevTools AI Assistant added this, which I didn't read but looks interesting:
"Explanation
Okay, let's break down why you're getting the "Failed to fetch ... Import failed 3 times. Final error: crypto.randomUUID is not a function" error and how to fix it.
Understanding the Error
The error message tells us a few critical things:
- Failed to Fetch: The browser is trying to load a JavaScript file from a Chrome extension ( chrome-extension://khgocmkkpikpnmmkgmdnfckapcdkgfaf/inline/injected.js).
- Import Failed 3 Times: The browser attempted to load the file three times and failed each time. This suggests the issue is not a temporary network hiccup but something fundamental.
- crypto.randomUUID is not a function: This is the root cause of the failure. The crypto.randomUUID() method is a relatively new web standard (part of the Web Crypto API) that is used to generate cryptographically secure UUIDs. The browser (or, more likely, the context where this code is running) doesn't support it.
Where the Problem Likely Lies
The problem is most likely in the injected.js file, as the error is complaining about something inside this extension file. Although the error is shown while your web app is working, the problem is not with your app code itself, but rather, the extension injecting this injected.js file.
- Older Extension Code: The extension is injecting a file that uses crypto.randomUUID(). If the extension was built targeting an older version of Chrome or a different browser that didn't support crypto.randomUUID(), this method may have been added later or not added by the extension authors.
- Old browser version: An old browser version may not support crypto.randomUUID.
Why Your Web App Code is Involved (Indirectly)
Your web app's code triggers the extension's injection mechanism. Your code doesn't directly use crypto.randomUUID().
Dissecting the Given Code (and How it Relates)
Let's look at the code snippet you provided and see how it contributes to triggering the error, even if it's not causing it:
Code
(l),i.filter(p).forEach(s=>{let u=b();e.addEventListener("DOMContentLoaded",()=>{l(s).then(u.resolve)},{once:!0}),a=[...a,u.promise]})):(`${n}`,a=[...c,...i].filter(p).map(l)),Promise.all(a)},y=()=>{let e=chrome.runtime.getURL(""),t=new URL(e),r=t.protocol,o=t.host;return`${r}//${o}`},m=(e,t)=>{chrome.runtime.sendMessage({name:"report-error",data:{name:"InjectContentScript",message:e,severity:"error",stack:t}})},S=(e,t)=>{if(!h(e)){console.error(t),m(t);return}let r=`${t}, ${e.message}`;console.error(r),m(r,e.stack)},l=async e=>{if(`${n}${e.label}`,e.world==="ISOLATED")try{await C(e.path)}catch(t){return S(t,`Failed to fetch ${e.path}`),Promise.resolve(void 0)}else{let t="Only isolated script injection has been supported";throw m(t),new Error(t)}},C=async e=>{let t=[];try{await T(e);return}catch(i){t.push(i)}await d(25);try{await import(e);return}catch(i){t.push(i)}await d(50);try{await import(e);return}catch(i){t.push(i)}if(t.length===0)throw new Error("Logic error: unreachable code w
Use code snippets with caution
- Content Script Injection: The code heavily suggests that it's part of a system for dynamically injecting content scripts (scripts that run in the context of a web page) into web pages. This is common for browser extensions.
- l Function: This is likely the main function for managing the injection of a script. It checks if the target world is "ISOLATED" (a way of running a script in a sandboxed environment).
- C Function: This is the function that actually attempts to load the script. It tries import() three times, with delays (d(25), d(50)) in between each attempt. The file it tries to import is given in e.path. The error message we are getting is probably coming from this code.
- chrome.runtime.getURL(): This function is crucial for extensions. It is getting the URL to fetch files from the extension itself. This makes the browser look inside the extension for the injected.js file.
- Error reporting: The code contains functions m and S which are sending errors to the extension, probably for debug or error tracking purposes.
- import(e): The repeated import(e) is the exact point where the error happens. When the injected.js is being imported, it uses the crypto.randomUUID, and since it is unsupported, it fails.
Solution and Workarounds
Since the problem is in an external extension file, you cannot directly modify the injected.js code. Your solutions are more about working around the issue or ensuring the extension is updated:
- Update the Extension:
- If the extension is from the Chrome Web Store, check if there's an update available. The extension's developer may have fixed this bug.
- Contact the extension support and report the issue.
- Find an Alternative Extension:
- If updating doesn't work or there's no update, see if there's a different extension that offers similar functionality and doesn't have this problem.
- Polyfill:
- If the extension is not maintained, a way to avoid the issue could be to implement a polyfill.
- This polyfill could be injected before the extension's injected.js and would create the crypto.randomUUID if it doesn't exists.
- Disable the Extension:
- If you don't need the extension at all, disable it in your browser's extension settings.
- Use a different browser:
- An old browser version could be the cause of the issue. Try using a newer browser version.
Important Considerations
- Security: Be cautious about disabling security-related extensions. Make sure you understand the risks involved.
- Extension Development: If you are the developer of the extension, replace crypto.randomUUID() by a compatible UUID method or add a polyfill.
In Summary
The error "crypto.randomUUID is not a function" in your scenario means that the injected.js file within the extension is trying to use a feature that's not available in the execution environment. You can fix this by updating or replacing the extension, or by using a polyfill. You must investigate which extension is injecting this file.
Data used to understand this message
Use search instead
AI tools may generate inaccurate info that doesn't represent Google's views. Data sent to Google may be seen by human reviewers to improve this feature. Open settings or learn more
- 1P_Dave
Moderator
Hello JamieRI! 👋
I'm sorry that you're seeing an unexpected error message in the console when using 1Password. The error message that you've reported matches a known issue that our developers released a fix for in version 8.10.58 of 1Password in the browser which was released back in January. Please update:
If you still see the issue with the latest version of 1Password then please let me know.-Dave
!27383