e47c13f177
And recreate it if it does not exist. In windows, electron renderer process will crash if: 1. Import some NAPI module that enable `tokio-rt` flag in renderer process. 2. Reload the page. 3. Call a function imported from that NAPI module. Because the tokio runtime will be dropped when reloading the page, and won't create again, but currently we assume that the runtime must exist in tokio-based `within_runtime_if_available`. This will cause some panic like this: ``` thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', napi-rs\crates\napi\src\tokio_runtime.rs:72:42 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Error: Renderer process crashed: crashed, exitCode: -529697949 at EventEmitter.<anonymous> (napi-rs\examples\napi\electron.js:33:9) at EventEmitter.emit (node:events:525:35) ```
13 lines
320 B
HTML
13 lines
320 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Electron test</title>
|
|
</head>
|
|
<body>
|
|
<div>Electron test</div>
|
|
<script src="./index.js"></script>
|
|
</body>
|
|
</html>
|