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

fix(ext/node): node compatibility issue missing fd in createServer callback socket object #27789

Merged
merged 9 commits into from
Feb 26, 2025

Conversation

muthu90tech
Copy link
Contributor

@muthu90tech muthu90tech commented Jan 23, 2025

This PR will address the node compatibility issue where, the callback socket object in net.createServer is missing a fd in socket._handle

Modified this PR to use internal symbol to expose fd instead of exposing it via lib.deno.d.ts
denoland/deno_core#1061

fixes: #27788

muthu90tech added a commit to muthu90tech/deno_core that referenced this pull request Jan 25, 2025
please take a look at this PR: denoland/deno#27789
Use an internal symbol to expose fd created after establishing a socket connection
in the server side.
The node apis expose fd, this ensures the deno node apis are compatible.
muthu90tech added a commit to muthu90tech/deno_core that referenced this pull request Jan 25, 2025
…ol in deno_core

Please take a look at PR: denoland/deno#27789
This change will help to expose fd to server when a socket connection is
established.
@bartlomieju
Copy link
Member

@muthu90tech I merged your deno_core PR. It will be a few days before it gets released, so for now you can use Cargo patch functionality to point to a latest commit on main branch in deno_core instead of a fixed version.

@muthu90tech
Copy link
Contributor Author

@muthu90tech I merged your deno_core PR. It will be a few days before it gets released, so for now you can use Cargo patch functionality to point to a latest commit on main branch in deno_core instead of a fixed version.

Thanks @bartlomieju , Once the deno_core version with the fix is released, should I update the current PR to point to the deno_core version with the fix, or will that be handled ? Thank you

@muthu90tech
Copy link
Contributor Author

@muthu90tech I merged your deno_core PR. It will be a few days before it gets released, so for now you can use Cargo patch functionality to point to a latest commit on main branch in deno_core instead of a fixed version.

Thanks @bartlomieju , Once the deno_core version with the fix is released, should I update the current PR to point to the deno_core version with the fix, or will that be handled ? Thank you

@bartlomieju , I noticed main branch has deno_core 0.336.0, which has the new symbol, so I rebased. Thanks

Copy link
Contributor Author

@muthu90tech muthu90tech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api to get the fd in tokio library is not implemented on windows, I notice build issues around it. Is there a way to exclude implementation just for windows, like a MACRO ? thank you

@kt3k
Copy link
Member

kt3k commented Feb 18, 2025

Is there a way to exclude implementation just for windows, like a MACRO ? thank you

You can use #[cfg(unix)], #[cfg(windows)], etc for writing OS specific code. ref

deno/ext/fs/std_fs.rs

Lines 643 to 646 in 17a51c4

#[cfg(unix)]
std::os::unix::fs::symlink(from, to)?;
#[cfg(windows)]
std::os::windows::fs::symlink_file(from, to)?;

…lback socket object

This PR will address the node compatibility issue where, the callback socket
object in net.createServer is missing a fd in socket._handle

fixes: denoland#27788
Copy link
Contributor Author

@muthu90tech muthu90tech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kt3k , I addressed the lint issues, but when running the integration tests locally even without my changes I see 60 failures, I noticed the integration failed in CI too, are there flaky issues with test bed? Thank you

@muthu90tech
Copy link
Contributor Author

@kt3k , I addressed the lint issues, but when running the integration tests locally even without my changes I see 60 failures, I noticed the integration failed in CI too, are there flaky issues with test bed? Thank you

Nvm, I think tests in CI are passing now.

@@ -180,14 +182,27 @@ pub async fn op_net_accept_tcp(
.try_or_cancel(cancel)
.await
.map_err(accept_err)?;
let mut _fd_raw: Option<Fd> = None;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: probably this shouldn't be prefixed with _ as the value is used later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kt3k , yes I initially had fd_raw, but the lint on linux complained about

error: value assigned to `fd_raw` is never read
   --> ext/net/ops.rs:185:11
    |
185 |   let mut fd_raw: Option<Fd> = None;
    |           ^^^^^^
    |
    = help: maybe it is overwritten before being read?
    = note: `-D unused-assignments` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(unused_assignments)]`


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Makes sense

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits

@bartlomieju Can you take another look?

@kt3k kt3k changed the title fix(ext/net): node compatibility issue missing fd in createServer callback socket object fix(ext/node): node compatibility issue missing fd in createServer callback socket object Feb 26, 2025
@kt3k
Copy link
Member

kt3k commented Feb 26, 2025

Thanks for your contribution!

@kt3k kt3k merged commit 1a30b74 into denoland:main Feb 26, 2025
18 checks passed
littledivy pushed a commit that referenced this pull request Mar 5, 2025
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

Successfully merging this pull request may close these issues.

Deno node compatibility issue where the callback object in net.createServer is missing fd
3 participants