Skip to content

fix(repl): use object_id for repl internal #29163

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

CyanChanges
Copy link
Contributor

@CyanChanges CyanChanges commented May 5, 2025

close #26599
close #29121

This PR use object_id to interact with repl internal, instead of global variable (__DENO_REPL_INTERNALS_{seconds}__),
so we don't need to hide this in completions, etc.

Also add some error handling instead of simply unwrap.

Before this PR

image
image

After the PR

image

image

btw, the the code in #26599 still create an error, may be we need to dive into this after merging this pr.
image
UPDATE deno_console seemly using globalThis for Intl and Temporal for prototype checks?
UPDATE: Open #29165 for this

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.

Thanks, a few comments

format!("__DENO_REPL_INTERNALS_{seconds}__")
});

thread_local! {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of using a thread_local here - consider storing this object id on ReplSession object

cli/cdp.rs Outdated
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for changes to all of these structs? It's very surprising that something that is deserialized from JSON uses non-owned string types of Arc. I suggest you revert these changes

Cargo.lock Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Please revert all these changes

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.

Please keep required changes to a minimum, there's a ton of changes that are not necessary here

cli/cdp.rs Outdated
Comment on lines 301 to 302
pub type RemoteObjectId = str;
pub type OwnedRemoteObjectId = <RemoteObjectId as ToOwned>::Owned;
Copy link
Member

Choose a reason for hiding this comment

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

Revert

cli/cdp.rs Outdated
Comment on lines 308 to 309
pub type ScriptId = str;
pub type OwnedScriptId = <ScriptId as ToOwned>::Owned;
Copy link
Member

Choose a reason for hiding this comment

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

Revert

@@ -339,15 +335,15 @@ impl JupyterServer {
// combine results of declarations and globalThis properties
let mut candidates = get_expression_property_names(
&mut self.repl_session_proxy,
"globalThis",
GLOBALTHIS_EXPRESSION,
Copy link
Member

Choose a reason for hiding this comment

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

What is this used for?

EvaluationOutput::Error(format!("{} {:#}", colors::red("error:"), err))
}
}
r.unwrap_or_else(|err| {
Copy link
Member

Choose a reason for hiding this comment

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

This is an unrelated change, please revert it

@CyanChanges CyanChanges marked this pull request as draft May 8, 2025 16:22
@CyanChanges CyanChanges marked this pull request as ready for review May 9, 2025 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants