Skip to content

Commit

Permalink
Merge pull request #155 from pyscript/randomUUID
Browse files Browse the repository at this point in the history
Add FAQ not about randomUUID related error.
  • Loading branch information
ntoll authored Dec 7, 2024
2 parents 86d69a8 + 0ae1660 commit f1438ae
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,37 @@ for the main thread to call functions defined in the worker in a non-blocking
manner, thus allowing the worker to also work in an unblocked manner and react
to such calls. We have resolved the mutual deadlock.

### TypeError: crypto.randomUUID is not a function

If PyScript fails to start and you look in the browser console, you may
find the following error:

!!! failure

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

#### When

This happens because PyScript uses the `crypto.randomUUID` function, and the
web page isn't served correctly.

#### Why

This error is _created by the browser_ because `crypto.randomUUID` requires a
secure context or localhost to use the latest web standards that are part of
PyScript's core (such as `crypto.randomUUID`).

Put simply, your code should be served from a domain secured
with TLS (i.e. the domain name starts with `https` - use a service like
[let's encrypt](https://letsencrypt.org/) to address this) or from `localhost`
if developing and viewing your site on your development machine.

This is something PyScript can't fix. Rather, it's how the web works and you
should always ensure your code is served in a secure manner.

## Helpful hints

This section contains common hacks or hints to make using PyScript easier.
Expand Down

0 comments on commit f1438ae

Please sign in to comment.