Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: JSG lock error when running locally #3289

Closed
rodbs opened this issue May 18, 2023 · 27 comments
Closed

🐛 BUG: JSG lock error when running locally #3289

rodbs opened this issue May 18, 2023 · 27 comments
Labels
bug Something that isn't working

Comments

@rodbs
Copy link

rodbs commented May 18, 2023

Which Cloudflare product(s) does this pertain to?

Wrangler

What version of Wrangler are you using?

3.0.0

What operating system are you using?

Windows 10

Describe the Bug

I'm trying to run Remix (1.16.1) on Pages locally (Win10(. It works with Wrangler 2, but after upgrading to Wrangler 3, it doesn't work producing several errors:

[ERROR] No matching export in "../../Users/rodri/AppData/Local/Temp/functionsWorker-0.19168769412996323.mjs" for import "default"

    ../../Users/rodri/AppData/Local/Temp/tmp-22076-Wi4LUibqhmZQ/middleware-insertion.entry.js:2:7:
      2 │ import worker from "C:\\Users\\rodri\\AppData\\Local\\Temp\\functio...
workerd/jsg/jsg.c++:98: error: took recursive isolate lock; kj::getStackTrace() = 7ff7d1b3a54e 7ff7d17baa24 7ff7d19b6e06 7ff7d19ef9ca 7ff7d19ef912 7ff7d15689b5 7ff7d20e7e7e 7ff7d20ad54b 7ff7d179281a 7ff7d16a3a01 7ff7d1d7eebf 7ff7d16a3a01 7ff7d1d7f80c 7ff7d16a3a01 7ff7d090c23c 7ff7d16a5f12 7ff7d16a3a01 7ff7d090c23c 7ff7d16a4e24 7ff7d16a3a01 7ff7d1a9eefc 7ff7d16a3a01 7ff7d090c23c 7ff7d16a4e24 7ff7d16a3a01 7ff7d1a9f6bc 7ff7d16a3a01 7ff7d1aa039c 7ff7d16a4e24 7ff7d16a3a01
@rodbs rodbs added the bug Something that isn't working label May 18, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk May 18, 2023
@Jackardios
Copy link

I get the same error intermittently on macOS with remix-run 1.16.1

workerd/jsg/jsg.c++:98: error: took recursive isolate lock; kj::getStackTrace() = 10b4d7c39 10b808f12 10b832f01 10b832e86 10cf8e7af 10bb4fe3d 10ba9a895 10ba9aab2 10cf598a2 10b93d4c1 10cf59c92 10b93df91 10cf59c92 10b7e7741 10cf5b973 10cf59c92 10b7e8651 10cf5ab23 10cf598a2 10b7e94a1 10cf59c92 10b7e95c1 10cf5ab23 10cf598a2 10b7e9ac1 10cf59c92 10b

@AdiRishi
Copy link

AdiRishi commented May 21, 2023

I ran into this too.

workerd/jsg/jsg.c++:98: error: took recursive isolate lock; kj::getStackTrace() = 104fcf23b 10526d2c7 10528fb53 10528fad7 1066abd8f 1054fd0b3 10546828b 1054684b3 10667e61b 10535a2ab 10667e943 10535ad97 10667e943 10525262f 1066802c3 10667e943 105253223 10667f5ef 10667e61b 105253e57 10667e943 105253f83 10667f5ef 10667e61b 105254367 10667e943 105255607 10667f5ef 10667e61b

I am running MacOS, wrangler 3.0.0. I managed to trigger this by ingesting a number of events in a queue and they all read-write from KV in some way. Nothing unreasonable, and I know this process works in the actual remote cloudflare environment. It also worked in wrangler v2.

Edit: In case it's a point of curiosity, I wasn't running remix at all, this was all cloudflare workers running locally.

@penalosa
Copy link
Contributor

Thanks for reporting this! Would you be able to post a minimal reproduction, and we can investigate further?

@rodbs
Copy link
Author

rodbs commented May 22, 2023

The minimal repo is to create a Remix app on Cloudflare Pages and upgrade it to wrangler 3.0.0. It fails when running it:
https://github.com/rodbs/remix-workers

✨ Compiled Worker successfully
 ⛅️ wrangler 3.0.0
------------------
wrangler dev now uses local mode by default, powered by 🔥 Miniflare and 👷 workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
⎔ Starting local server...
▲ [WARNING] Parsed 1 valid header rule.


[mf:wrn] The latest compatibility date supported by the installed Cloudflare Workers Runtime is "2023-05-18",
but you've requested "2023-05-22". Falling back to "2023-05-18"...
service core:user:worker: The compatibility flag streams_enable_constructors became the default as of 2022-11-30 so does not need to be specified anymore.
X [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.

The error in the first post was when trying to connect to a db to fetch some data.

@patsaas
Copy link

patsaas commented May 22, 2023

Similar intermittent error upon requests using wrangler 3.0.1 on macOS Ventura 13.3 & 13.4, and using Remix 1.16.1 with the Cloudflare Pages adapter.

workerd/jsg/jsg.c++:133: error: took recursive isolate lock; kj::getStackTrace() = 102beb23b 102e8c017 102eaef97 102eaef1b 1042d7e03 103123e0b 10308b88f 10308bab7 1042aa68f 102f7b98b 1042aa9b7 102f7c477 1042aa9b7 102e71257 1042ac337 1042aa9b7 102e71e4b 1042ab663 1042aa68f 102e72a7f 1042aa9b7 102e72bab 1042ab663 1042aa68f 102e72f8f 1042aa9b7 102e7422f 1042ab663 1042aa68f

@jbergstroem
Copy link

Same for me in a cloudflare worker / proxy project using wrangler 3.0.1 with local development:

workerd/jsg/jsg.c++:98: error: took recursive isolate lock; kj::getStackTrace() = 106a8bc39 106dbcf12 106de6f01 106de6e86 1085427af 1074f6963 108518c73 108565925 108510630 10850d8a2 106de7bc1 10850d8a2 1074ee8a1 10850dc92 1074ee4c1 1085134ce 10850d8a2 1074edeb1 1074edd1e 1074edfdf 106f5ae5f 106f62a4f 106f629b8 106d700fe 106f6456c 1077cfb6f 1077cf6f9 1077cee35 1076662f4

uname: Darwin jess.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_6

@mjaskolski
Copy link

mjaskolski commented May 29, 2023

Same for me with wrangler 3.0.1 and macOS 13.4 Beta (22F5037d)

workerd/jsg/jsg.c++:133: error: took recursive isolate lock; kj::getStackTrace() = 102b6723b 102e08017 102e2af97 102e2af1b 104253e03 10309fe0b 10300788f 103007ab7 10422668f 102ef798b 1042269b7 102ef8477 1042269b7 102ded257 104228337 1042269b7 102dede4b 104227663 10422668f 102deea7f 1042269b7 102deebab 104227663 10422668f 102deef8f 1042269b7 102df022f 104227663 10422668f

Usually in comparison with streaming, as in
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
while (true) {
const { value, done } = await reader.read();
(...)

@penalosa penalosa added the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Jun 15, 2023
@lrapoport-cf lrapoport-cf assigned jspspike and unassigned jspspike Jun 19, 2023
@jspspike jspspike removed the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Jun 19, 2023
@jspspike jspspike moved this from Untriaged to Backlog in workers-sdk Jun 19, 2023
@jspspike jspspike changed the title 🐛 BUG: 🐛 BUG: JSG lock error when running locally Jun 19, 2023
@bardia-pourvakil
Copy link

running into the same issue running CF worker on macOS Apple M2 Pro chip with Ventura 13.3.1

seems to happen intermittently when calling the same endpoint that returns a stream from OpenAI

@aroman
Copy link

aroman commented Jun 25, 2023

also getting this, Ventura 13.4.1, wrangler 3.1.1

@rodbs
Copy link
Author

rodbs commented Jun 27, 2023

Just upgraded to Remix 1.18.0 with wrangler 3.1.1 and still getting the error:

service core:user:worker: Uncaught Error: Some functionality, such as asynchronous I/O, timeouts, and generating random values, can only be performed while handling a request.
  at 6efkc5hzhoc.js:63911:24 in FSWatcher2._this._persist
  at 6efkc5hzhoc.js:63926:140 in FSWatcher2.start
  at 6efkc5hzhoc.js:63742:22 in Volume2.watch
  at 6efkc5hzhoc.js:64033:7 in watchStdo
  at 6efkc5hzhoc.js:64029:1
X [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.

@ugudango
Copy link

I can confirm this is still happening, wrangler@beta and running Arch Linux.
workerd/jsg/jsg.c++:133: error: took recursive isolate lock; kj::getStackTrace() =

@bhirmbani
Copy link

i got this too wrangler v3.1.1

workerd/jsg/jsg.c++:133: error: took recursive isolate lock; kj::getStackTrace() = 10282b23b 102acc017 102aeef97 102aeef1b 103f17e03 102d63e0b 102ccb88f 102ccbab7 103eea68f 102bbb98b 103eea9b7 102bbc477 103eea9b7 102ab1257 103eec337 103eea9b7 102ab1e4b 103eeb663 103eea68f 102ab2a7f 103eea9b7 102ab2bab 103eeb663 103eea68f 102ab2f8f 103eea9b7

@tcornolti
Copy link

I'm getting the same error with Wrangler v3.1.1/macOS 13.4.1 (arm)

workerd/jsg/jsg.c++:133: error: took recursive isolate lock; kj::getStackTrace() = 10462323b 1048c4017 1048e6f97 1048e6f1b 105d0fe03 104b5be0b 104ac388f 104ac3ab7 105ce268f 1049b398b 105ce29b7 1049b4477 105ce29b7 1048a9257 105ce4337 105ce29b7 1048a9e4b 105ce3663 105ce268f 1048aaa7f 105ce29b7 1048aabab 105ce3663 105ce268f 1048aaf8f 105ce29b7 1048ac22f 105ce3663 105ce268f

@gp27
Copy link

gp27 commented Jul 13, 2023

I'm getting the same error with wrangler v3.2.0 running on linux_64
workerd/jsg/jsg.c++:133: error: took recursive isolate lock; kj::getStackTrace() = 168bbf9 1918fe0 19502a5 1950206 31bc45f 1f50190 3191a13 31df485 3191cb4 318ec22 1950f01 318ec22 2197d9e 318f022 21979c1 18982ff 318ec22 21977b1 219761e 21978da 19d7d7a 1d32f0f

@aaronadamsCA
Copy link

Just upgraded to Remix 1.18.0 with wrangler 3.1.1 and still getting the error:

service core:user:worker: Uncaught Error: Some functionality, such as asynchronous I/O, timeouts, and generating random values, can only be performed while handling a request.
  at 6efkc5hzhoc.js:63911:24 in FSWatcher2._this._persist
  at 6efkc5hzhoc.js:63926:140 in FSWatcher2.start
  at 6efkc5hzhoc.js:63742:22 in Volume2.watch
  at 6efkc5hzhoc.js:64033:7 in watchStdo
  at 6efkc5hzhoc.js:64029:1
X [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.

FYI @rodbs, that specific error is probably remix-run/remix#6665.

@scottwillmoore
Copy link

scottwillmoore commented Jul 20, 2023

This error occurs for me without Remix.

export default {
	async fetch() {
		await fetch("https://google.com.au/");

		return new Response("Hello, world!");
	},
} satisfies ExportedHandler;

I use NixOS, and have created a reproduction at scottwillmoore/cloudflare-workers-with-nix, although I don't know if it will help much as Nix can be difficult to use for first-time users.

EDIT: My reproduction uses wrangler@3.3.0.

@aaronadamsCA
Copy link

Oh, I should mention, I do get this error intermittently too, on Ubuntu 22.04.2 LTS. Wrangler v3.2.0, under Remix with command wrangler pages dev public/ --compatibility-date=2023-03-14 --kv=KV_SESSIONS --local-protocol=https.

@chr33s
Copy link

chr33s commented Jul 26, 2023

@scottwillmoore try env.ASSETS.fetch instead of fetch, solved it for me.

@scottwillmoore
Copy link

scottwillmoore commented Jul 30, 2023

@chr33s The env.ASSETS.fetch function is for Cloudflare Pages and used for local assets right? I didn't spend much time looking into it, but it didn't work to replace my use-case of fetch. I am also not using Cloudflare Pages and my request is for https://google.com.au/ (not local assets).

@jacobpake
Copy link

This is more of a warning than an error; nothing will actually go wrong.

cloudflare/workerd#706 (comment)

I see lots of these warnings when making multiple requests to the Cache API

@chr33s
Copy link

chr33s commented Jul 31, 2023

@scottwillmoore true, my usecase was local files. I missed the "google.com.au" bit.

@xdivby0
Copy link

xdivby0 commented Oct 3, 2023

I get the workerd/jsg/jsg.c++:136: error: took recursive isolate lock; error in my application after upgrading from wrangler v2 to v3 as well. Weirdly it just triggers on some requests and I couldn't see figure out a pattern, it's not consistent for which routes trigger that error.

Also, I didn't notice anything not working. Everything in my app still works fine, I can't see any request timeouts or stuff.

@gregory
Copy link

gregory commented Nov 24, 2023

still an issue with wrangler 3.17.1, even after #1415 got merged - I'm seeing the following over and over...

  workerd/jsg/jsg.c++:136: error: took recursive isolate lock; kj::getStackTrace() = 1010321d9
  10161ebea 101638f11 101638e96 1033333ef 1019beefa 1019bffa6 1018fab25 1018fad42 1032ff0e2
  101763a91 1032ff4d2 101764601 1032ff4d2 1015f8b41 1033011c3 1032ff4d2 1015f9a51 103300363
  1032ff0e2 1015fa0e1 1032ff4d2 1015fa201 103300363 1032ff0e2 1015fa701 1032ff4d2 1015fb9d1
  103300363

@zwily
Copy link
Contributor

zwily commented Dec 6, 2023

Also getting this in 3.19.0:

✘ [ERROR] workerd/jsg/jsg.c++:136: error: took recursive isolate lock; kj::getStackTrace() = 102588b8b 102a55047 102a68d4b 102a68ccf 1043bf5c7 102eb979b 10439e4cb 1043dbbf7 1043979ab 104398a8b 102a795cf 104398983 10439577b 10333b337 104395ab3 10333afcf 10256785f 10439577b 10333ac83 10333ab0f 10333adc7 102aea873 102bba5e3 102bb8f3f 102d45c9f 102ca592f 102a126bf 102c93dcb 102c8013f

(This seems to be the only "non-actionable" warning left now that a bunch have been cleaned up...)

@ducan-ne
Copy link

I'm also experiencing this issue with version 3.18.0. I'm unsure how to resolve it, but here's the log for reference.

 workerd/jsg/jsg.c++:136: error: took recursive isolate lock; kj::getStackTrace() = 104724b8b 104bf1047 104c04d4b 104c04ccf 10655b5c7 10505579b 10653a4cb 106577bf7 1065339ab 106534a8b 104c155cf 106534983 10653177b 1054d7337 106531ab3 1054d6fcf 10470385f 10653177b 1054d6c83 1054d6b0f 1054d6dc7 104c86873 104c83fa7 104c83ef7 104bae6bf 104d599eb 1055c313f 1056b8777 1055e7f87

@mrbbot
Copy link
Contributor

mrbbot commented Jan 2, 2024

Hey everyone! 👋 This error isn't user actionable, and was meant for internal debugging (cloudflare/workerd#706 (comment)). As of wrangler@3.21.0 (#4511), the error should be suppressed. Thanks @huw!

@mrbbot mrbbot closed this as completed Jan 2, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in workers-sdk Jan 2, 2024
@non-bin
Copy link

non-bin commented Jan 19, 2025

Anyone having this issue on NixOS, use

export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

as suggested here https://github.com/scottwillmoore/cloudflare-workers-with-nix?tab=readme-ov-file

Or add this to your home-manager config

{
  home.sessionVariables = {
    SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt";
  };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
Development

No branches or pull requests