question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`crypto.randomUUID()` fails on mobile in Dev

See original GitHub issue

Describe the bug

<!-- routes/+page.svelte -->
<script>
	let arr = [];
	const add = () => (arr = [{ id: crypto.randomUUID() }, ...arr]);
</script>

<button on:click={add}>add</button>
{#each arr as item (item.id)}
	<p>{item.id}</p>
{/each}
npm run dev -- --host

  VITE v3.2.4  ready in 681 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: http://192.168.X.X:5173/

open Network in dev mode on mobile and click add button. Not working deploy on vercel site open on mobile. Working

Reproduction

repo

Logs

No response

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 AMD Ryzen 9 5900HS with Radeon Graphics
    Memory: 7.96 GB / 15.41 GB
  Binaries:
    Node: 18.0.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.819.0), Chromium (107.0.1418.42), ChromiumDev ((@(&"C:/Users/dange/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh.exe" init pwsh --config="C:\Users\dange\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json" --print) -join "`n") | Invoke-Expression)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.88
    @sveltejs/kit: next => 1.0.0-next.551
    svelte: ^3.44.0 => 3.53.1
    vite: ^3.1.0 => 3.2.4

Severity

serious, but I can work around it

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Rich-Harriscommented, Nov 19, 2022

Presumably the problem is that the mobile browser is connecting to http://192.168.X.X:5173/ rather than localhost? Not sure there’s a lot we can do about that, and it isn’t specific to SvelteKit, so I’m inclined to close this as wontfix

0reactions
Rich-Harriscommented, Nov 20, 2022

We just can’t be responsible for documenting every aspect of the web platform — we’re not MDN (where the secure context limitation is called out at the top of the page). Closing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Property 'randomUUID' does not exist on type 'Crypto' #12754
mod.ts const random = crypto.randomUUID();. Running deno run --config deno.jsonc mod.ts causes the following error: error: TS2339 [ERROR]: ...
Read more >
NodeJS, crypto.randomUUID is not a function - Stack Overflow
I'm very new to JS, I want to generate an UUID. Here's what I tried, step by step: mkdir test; cd test; touch...
Read more >
Crypto.randomUUID() - Web APIs - MDN Web Docs
The randomUUID() method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
Read more >
Node.js crypto.randomUUID( ) Function - GeeksforGeeks
randomUUID() is an inbuilt application programming interface of class Crypto within crypto module which is used to generate a random RFC 4122 ...
Read more >
crypto.randomUUID is three times faster uuid.v4
Node.js v14.17 release added crypto.randomUUID() . This method allows to generate random RFC 4122 Version 4 UUID strings. Example:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found