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

Unable to run basic example: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'path') #2

Closed
johanndev opened this issue Nov 9, 2021 · 6 comments

Comments

@johanndev
Copy link

Hi!

I'm unable to run the basic worker example.

System information

Windows 10 Version 21H1 (OS Build 19043.1288)

➜ deno --version
deno 1.15.3 (release, x86_64-pc-windows-msvc)
v8 9.5.172.19
typescript 4.4.2

Steps to reproduce:

  1. Install denoflare:
    deno install --unstable --allow-read --allow-net --allow-env --name denoflare --force https://raw.githubusercontent.com/skymethod/denoflare/v0.3.0/cli/cli.ts

  2. Clone the denoflare repository and open a command line in the examples/hello-worker directory

  3. Run example via: denoflare serve .\hello.ts, this results in:

➜ denoflare serve .\hello.ts
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'path')      
    const scriptPathOrUrl = scriptUrl ? scriptUrl.toString() : script!.path;
                                                                       ^
    at serve (https://raw.githubusercontent.com/skymethod/denoflare/v0.3.0/cli/cli_serve.ts:94:72)
    at async https://raw.githubusercontent.com/skymethod/denoflare/v0.3.0/cli/cli.ts:14:13    
@johnspurlock-skymethod
Copy link
Contributor

Hi there - denoflare is still in the early stages of development, but I'll try to help you get started.

Thanks for the repro steps and info - this error message is not the greatest, I'll see if I can put something better in there.

Also I'm not sure if anyone's tried this yet on Windows - I'll try to reproduce this in a vm today and see if there's something inherently different in path checking/detection.

In the meantime you might try creating a configuration file with a script config to give your script a name, it will come in handy for running/deploying/specifying options/env vars args in the future.

@johnspurlock-skymethod
Copy link
Contributor

It might not be Windows-specific after all. Was able to reproduce locally on a simple local script without a config file.

Just released 0.3.1 that should fix that problem, and updated the docs page. Upgrade (below), then try it again and let me know how it goes

deno install --unstable --allow-read --allow-net --allow-env --name denoflare --force https://raw.githubusercontent.com/skymethod/denoflare/v0.3.1/cli/cli.ts

@johanndev
Copy link
Author

Thanks for your investigation!

Upgrading to 0.3.1 and re-running the hello-worker sample produces:

➜ denoflare serve .\hello.ts
Compiling https://raw.githubusercontent.com/skymethod/denoflare/v0.3.1/cli-webworker/worker.ts into worker contents...
Compiled https://raw.githubusercontent.com/skymethod/denoflare/v0.3.1/cli-webworker/worker.ts into worker contents in 329ms
runScript: .\hello.ts
Compiled .\hello.ts into module contents in 164ms
worker: start
Started in 534ms (isolation=isolate)
Local server running on http://localhost:8080
Error in initWatcher TypeError: Must be an absolute path.
    at toFileUrl (https://deno.land/std@0.109.0/path/win32.ts:998:11)
    at computeDenoGraphLocalPaths (https://raw.githubusercontent.com/skymethod/denoflare/v0.3.1/cli/deno_graph.ts:4:37)
    at ModuleWatcher.initWatcher (https://raw.githubusercontent.com/skymethod/denoflare/v0.3.1/cli/module_watcher.ts:31:29)
    at new ModuleWatcher (https://raw.githubusercontent.com/skymethod/denoflare/v0.3.1/cli/module_watcher.ts:14:14)
    at createLocalRequestServer (https://raw.githubusercontent.com/skymethod/denoflare/v0.3.1/cli/cli_serve.ts:138:40)
    at async serve (https://raw.githubusercontent.com/skymethod/denoflare/v0.3.1/cli/cli_serve.ts:144:32)
    at async https://raw.githubusercontent.com/skymethod/denoflare/v0.3.1/cli/cli.ts:14:13

Despite the error message, the worker seems to be running - navigating to http://localhost:8080 produces a 200 response (Hello Cleveland!), the CLI shows:

fetchExternalIp: Fetching...
fetchExternalIp: Determined to be <redacted> in 109ms
GET http://localhost:8080/

I will try to run some of the other samples to see if the error is consistent.

@johnspurlock-skymethod
Copy link
Contributor

denoflare serve automatically watches the local module files and reloads on changes (in the default isolation=isolate mode)

So what's happening is your worker is being served, but the module scanner failed, so no reloads would happen automatically on changes. I believe I fixed this in master (installation below), want to give it a shot?

deno install --unstable --allow-read --allow-net --allow-env --name denoflare --force https://raw.githubusercontent.com/skymethod/denoflare/cb29abbf022213282adbfbd00fb7530f3f9a0324/cli/cli.ts

@johanndev
Copy link
Author

Hi!
The linked version fixes the error for me, reloading works correctly :)

@johnspurlock-skymethod
Copy link
Contributor

Great! Released v0.3.2 just now which includes that fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants