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(runtime): fix Deno.hostname on windows #16530

Merged
merged 5 commits into from
Nov 3, 2022

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Nov 3, 2022

This PR tries to fix Deno.hostname() issue on windows. This change starts winsocket before calling GetHostNameW as suggested in retep998/winapi-rs#296

closes #16527

// https://github.com/retep998/winapi-rs/issues/296
let wsa_startup_result = WSAStartup(MAKEWORD(2, 2), &mut data);
if wsa_startup_result != 0 {
panic!("Failed to start winsocket");
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should return String::from("") in this case?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. I'll try that in a later PR

Comment on lines 143 to 149
let mut data = mem::zeroed();
// Start winsock to make `GetHostNameW` work correctly
// https://github.com/retep998/winapi-rs/issues/296
let wsa_startup_result = WSAStartup(MAKEWORD(2, 2), &mut data);
if wsa_startup_result != 0 {
panic!("Failed to start winsocket");
}
Copy link
Member

Choose a reason for hiding this comment

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

This should be in a once_cell

@kt3k kt3k merged commit 6fe9428 into denoland:main Nov 3, 2022
@kt3k kt3k deleted the fix-hostname-windows branch November 3, 2022 19:00
DjDeveloperr pushed a commit to DjDeveloperr/deno that referenced this pull request Nov 4, 2022
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.hostname() returns empty string on some situation on windows
3 participants