Skip to content

Native REPL wrongly caches state from previous session #24359

Closed

Description

I'm not sure if I'm missing something, but I cannot find an option to restart the native REPL. If I just close the pane and then send another Python statement (Shift-Enter), it gets executed in the previously started native REPL (i.e., all created object in that session will still be available).

Activity

  1. anthonykim1 commented on Oct 31, 2024

    @anthonykim1

    Interesting, I can't seem to repro this.
    If you close the REPL tab via clicking on the x icon, It should launch new REPL for you when you try to send command again.
    Could you try "Python Clear cache and reload" and see if that helps?
    Also make sure it says "Python REPL" on the top right corner.

    Here is what happens for me on the latest version of vscode insider and python extension.

    Screen.Recording.2024-10-31.at.2.13.40.PM.mov
  2. added
    bugIssue identified by VS Code Team member as probable bug
    and removed
    feature-requestRequest for new features or functionality
    triage-neededNeeds assignment to the proper sub-team
    on Oct 31, 2024
  3. cbrnr commented on Nov 4, 2024

    @cbrnr
    Author

    No, this does not work for me. When I close the Native REPL tab and run a new command, it opens the previous REPL (in this example, x should not exist in a new REPL, but apparently this is still the same session):

    Screen.Recording.2024-11-04.at.15.41.22.mov

    When I run "Python: Clear Cache and Reload Window", the native REPL session is indeed closed and a new one is started. However, I don't think this is intended, as the REPL should either close when closing the tab or when selecting a dedicated "Trash" action (which does not exist, but this is how the integrated terminal works, so I think the native REPL should behave similarly).

  4. changed the title [-]Add option to restart native REPL[/-] [+]Native REPL wrongly caches state from previous session[/+] on Dec 10, 2024
  5. anthonykim1 commented on Dec 10, 2024

    @anthonykim1

    Hey Clemens Brunner (@cbrnr) Thanks for this, you are 100% correct.
    Will make sure this eventually gets resolved, I think this is very important.

  6. added
    needs PRReady to be worked on
    and removed
    info-neededIssue requires more information from poster
    on Dec 10, 2024
  7. hutch3232 commented on Feb 19, 2025

    @hutch3232

    I would love for this issue to be solved. I tried looking into it but haven't yet figured it out. I don't know typescript so it is tricky for me.

    I feel like in here:

    private watchNotebookClosed(): void {
    this.disposables.push(
    workspace.onDidCloseNotebookDocument(async (nb) => {
    if (this.notebookDocument && nb.uri.toString() === this.notebookDocument.uri.toString()) {
    this.notebookDocument = undefined;
    this.newReplSession = true;
    await updateWorkspaceStateValue<string | undefined>(NATIVE_REPL_URI_MEMENTO, undefined);
    }
    }),
    );
    }

    we need to run:

    nativeRepl = undefined;

    That way, in getNativeRepl it will create a new REPL.

    But that on its own is not sufficient. After closing the REPL, sending new code throws: notebook controller with id 'pythonREPL' ALREADY exist

    There is a setReplController method maybe we need an unsetReplController or something that gets called as well.

    With a bit of guidance I could look more into this. Thanks!

  8. added a commit that references this issue on Mar 1, 2025
    1a505d6
  9. anthonykim1 commented on Mar 8, 2025

    @anthonykim1

    Sorry, just saw this Paul (@hutch3232)
    Will take a look at the referenced PR and leave feedback there.

    Thanks very much for looking into this!

  10. added a commit that references this issue on Apr 2, 2025
    3275c34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-replbugIssue identified by VS Code Team member as probable bugneeds PRReady to be worked onverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions