Open otherjohn opened 1 year ago
There's been a regression after one of the recent Deno version upgrades, where sometimes an error in the script bubbles up as that rather unhelpful: Bad module.default: undefined
As a workaround, to try and see the actual underlying error, set the "localIsolation" to "none" (config property at the script level, ie a peer to "path" in your config.
After typing all of this, though, I think I see the issue: the "path" property value when pointing to a local file and not a url needs to be a full absolute path
Ok, I added the "localIsolation":"none"
to the .denoflare file. And I think you are right, looking at the "Download" below is a web address, and not local.
This is what I get before fixing the path
>denoflare serve main
Download ⠋ https://raw.githubusercontent.com/Users/John/xxxx/xxxx/deno-worker/src/first_s
Download ⠙ https://raw.githubusercontent.com/Users/John/xxxx/xxxx/deno-worker/src/first_s
Download ⠹ https://raw.githubusercontent.com/Users/John/xxxx/xxxxs/deno-worker/src/first_s
Download ⠸ https://raw.githubusercontent.com/Users/John/xxxx/xxxx/deno-worker/src/first_s
error: Uncaught (in promise) TypeError: Module not found "https://raw.githubusercontent.com/Users/John/xxxx/xxxx/deno-worker/src/first_steps.ts".
const module = await import(scriptPath);
^
at async Function.create (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/common/module_worker_execution.ts:19:24)
at async Function.start (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/common/worker_execution.ts:39:50)
at async createLocalRequestServer (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli_serve.ts:154:20)
at async Object.serve [as handler] (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli_serve.ts:190:32)
at async CliCommand.routeSubcommand (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli_command.ts:104:13)
at async https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli.ts:33:5
And after I fix the path by setting it to "./src/first_steps"
, it is the same thing but without the "Download"
>denoflare serve main
error: Uncaught (in promise) TypeError: Module not found "https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/common/src/first_steps.ts".
const module = await import(scriptPath);
^
at async Function.create (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/common/module_worker_execution.ts:19:24)
at async Function.start (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/common/worker_execution.ts:39:50)
at async createLocalRequestServer (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli_serve.ts:154:20)
at async Object.serve [as handler] (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli_serve.ts:190:32)
at async CliCommand.routeSubcommand (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli_command.ts:104:13)
at async https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli.ts:33:5
Still not sure hot to fix this though.
needs to be a full absolute path
Local file paths need to be absolute if using config: e.g. /Users/whatever/path/to/worker.ts
I get the exact same error even when I do my path like /Users/John/xxxx/xxxx/deno-worker/src/first_steps.ts
> denoflare serve main
Download ⠋ https://raw.githubusercontent.com/Users/John/xxxx/xxxx/deno-worker/src/first_s
Download ⠙ https://raw.githubusercontent.com/Users/John/xxxx/xxxx/deno-worker/src/first_s
error: Uncaught (in promise) TypeError: Module not found "https://raw.githubusercontent.com/Users/John/xxxx/xxxx/deno-worker/src/first_steps.ts".
const module = await import(scriptPath);
^
at async Function.create (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/common/module_worker_execution.ts:19:24)
at async Function.start (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/common/worker_execution.ts:39:50)
at async createLocalRequestServer (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli_serve.ts:154:20)
at async Object.serve [as handler] (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli_serve.ts:190:32)
at async CliCommand.routeSubcommand (https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli_command.ts:104:13)
at async https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/cli/cli.ts:33:5
I may have found a clue.
If I run denoflare serve main
I get the error,
but if I run denoflare serve ./src/first_steps.ts
it runs without error.
So it seems that something is up with it reading the path in the .denoflare
config file.
This is my .denoflare
config
{
"$schema": "https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/common/config.schema.json",
"scripts": {
"main": {
"path": "/Users/John/xxxx/xxxx/deno-worker/src/first_steps.ts",
"localIsolation": "none"
}
},
"profiles": {
"myprofile": {
"accountId": "xxxxxxxxxxxx",
"apiToken": "xxxxxxxxx"
}
}
}
Hi! @otherjohn, I stumbled upon this thread while debugging mine.
The issue I had was using the node library planetscale/database , as shown on the link. : How to use Planetscale with Deno
import { connect } from "npm:@planetscale/database@^1.6";
which ran with no issue locally (deno run), but it did using wrangler serve. Moving it to ESM solved the issue for me.
import { connect } from "https://esm.sh/@planetscale/database@1.6.0";
I doubt it's a version thing, since I've tried lowering it down .1 till 1.0 (using npm) but reached the same issue with wrangler. I don't know if its related to the bug you are seeing, but I found the same error you had, and i just started deleting imports till I found which one was causing it, because I wasn't seeing it on the debug log.
Hi, I am getting the following error when doing : "denoflare serve main"
Deno 1.28.3 denoflare v0.5.11
scripts.ts:
.denoflare
index.ts