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

feat(node): Add support for os.uptime #3052

Merged
merged 5 commits into from
Dec 29, 2022

Conversation

kamilogorek
Copy link
Contributor

Dependent on denoland/deno#17179

A part of denoland/deno#17850
This will also allow for out-of-the-box support for npm:@sentry/node, ref: getsentry/sentry-javascript#3009 (comment)

@lino-levan
Copy link
Contributor

LGTM. Nice work!

@lino-levan
Copy link
Contributor

@kamilogorek this should probably be un-drafted given that denoland/deno#17179 got merged?

@kamilogorek kamilogorek marked this pull request as ready for review December 27, 2022 17:23
@kt3k
Copy link
Member

kt3k commented Dec 28, 2022

@bartlomieju Do you think it's ok to require --unstable for os.uptime usage in npm compat? Or should we use Deno[Deno.internal].nodeUnstable namespace for bypassing --unstable requirement? (like #2839)

@bartlomieju
Copy link
Member

@bartlomieju Do you think it's ok to require --unstable for os.uptime usage in npm compat? Or should we use Deno[Deno.internal].nodeUnstable namespace for bypassing --unstable requirement? (like #2839)

Ah, good point; I forgot about that. Yeah I think it would be preferable to avoid --unstable here. Should I open a PR to do that?

@kamilogorek
Copy link
Contributor Author

I believe there's no need to rerun the tests after internal changes, as they were tested in denoland/deno itself.

node/os.ts Outdated
export function uptime(): number {
notImplemented(SEE_GITHUB_ISSUE);
return Deno.osUptime();
Copy link
Member

Choose a reason for hiding this comment

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

Please add

// @ts-ignore Deno[Deno.internal] is used on purpose here
const DenoOsUptime = Deno[Deno.internal]?.nodeUnstable?.osUptime || Deno.osUptime;

at the top of the file and use DenoOsUptime() here

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @kamilogorek

@bartlomieju bartlomieju merged commit 82c3291 into denoland:main Dec 29, 2022
@kamilogorek kamilogorek deleted the deno-uptime branch December 29, 2022 09:57
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.

None yet

4 participants