Skip to content

crypto.randomUUID is not a function when running locally #2326

@antocuni

Description

@antocuni

This is the content of my directory:
index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Proud Sunset</title>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">

    <link rel="stylesheet" href="https://pyscript.net/releases/2025.3.1/core.css">
    <script type="module" src="https://pyscript.net/releases/2025.3.1/core.js"></script>
</head>

<body>
    <script type="py" src="./main.py" config="./pyscript.toml" terminal></script>
</body>
</html>

pyscript.toml:

name = "Bug"

main.py:

print("hello world")

I tried to start a local web server:

❯ python -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

When opening the browser, the page is completely blank, and devtools shows this:

Uncaught TypeError: crypto.randomUUID is not a function
  at main.js:43:26

The same code works fine on pyscript.com:
https://pyscript.com/@antocuni/lingering-sound/latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions