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

Deno.listen shim: server._handle is null #140

Open
tjjfvi opened this issue Apr 10, 2023 · 1 comment
Open

Deno.listen shim: server._handle is null #140

tjjfvi opened this issue Apr 10, 2023 · 1 comment
Labels
bug Something isn't working help wanted

Comments

@tjjfvi
Copy link

tjjfvi commented Apr 10, 2023

import { Deno } from "@deno/shim-deno"

Deno.listen({ port: 8000 })
.../node_modules/@deno/shim-deno/dist/deno/stable/functions/listen.js:48
    const listener = new Listener_js_1.Listener(server._handle.fd, {
                                                               ^
TypeError: Cannot read properties of null (reading 'fd')
    at Object.listen (.../node_modules/@deno/shim-deno/dist/deno/stable/functions/listen.js:48:64)
    at .../test.ts:4:6
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
$ node -v
v18.14.0

https://github.com/denoland/node_shims/blob/main/packages/shim-deno/src/deno/stable/functions/listen.ts#L58-L59

@dsherret dsherret added bug Something isn't working help wanted labels Apr 12, 2023
@sgwilym
Copy link

sgwilym commented May 10, 2023

Looking at the code, it makes sense that this doesn't work. As the comment says:

// server._handle.fd is assigned immediately on .listen()

But we try to access server._handle.fd before the waitFor promise is called, so it can't be assigned yet.

It also looks like even if server._handle.fd was accessible, Listener is not assigning it to its own rid property: https://github.com/denoland/node_shims/blob/main/packages/shim-deno/src/deno/internal/Listener.ts#L6 (I just didn't understand this, sorry)

So it seems that server.listen needs to be reconstructed in some way to allow for the RID being the result of a promise.

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

No branches or pull requests

3 participants