Repository navigation
Keep R and Python connections open when Data Connections is enabled - #17228
Merged
Merged
Conversation
Contributor
|
E2E Tests 🚀 Why these tags?
More on automatic tags from changed files. Test count: Linux: 100 tests. |
juliasilge
marked this pull request as ready for review
November 9, 2026 23:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first step toward #16709!
With Data Connections enabled (the default since #16288), Positron disconnects the database connections that R and Python code opens. This PR stops that:
It does not yet show these connections in the Data Connections pane but I'll do an additional PR to add them there.
Cause
PositronConnectionsServiceclosed every connection comm when it arrived, because the old Connections pane is not registered when Data Connections is on. A close from the frontend runs the disconnect function of the connection itself in the kernel:client.dispose()sendscomm_closeto the kernel..ps.connection_close(id), which callscon$disconnect()._on_comm_closecalls_close_connection, which closes the object (for example,sqlite3callsconn.close()).As a result, a connection from
connections::connection_open()(or from anodbcconnection in R) was not valid after the next call. In Python,%connection_show conclosedcon.Change
PositronConnectionsServicenow keeps comms whose metadatalanguage_idisrorpythonopen, until the runtime closes them or the session ends. It closes all other comms as before (for example, ggsql comms).getSessionConnectionCode; that behavior does not change.get_metadataonly when R is idle, so a window reload during a long computation could cause this. Such a comm now takes the language of its session. The same rule applies when the metadata request fails. Before, the service closed these comms, and R then disconnected the user's object when it became idle.Release Notes
New Features
Bug Fixes
Validation Steps
@:connections
Unit tests are in
positronConnectionsService.vitest.tsandruntimeDataConnections.vitest.ts.To test this out manually, use a build with Data Connections enabled (the default).
R (needs the
connectionsandRSQLitepackages):Check that you have a
conobject and then run:The result is now
TRUE. Before this fix, it isFALSE. (connection_open()returns a wrapper, so the DBI connection is in itsconslot.)Python:
Then run:
The result is
(1,). Before this fix, Python showssqlite3.ProgrammingError: Cannot operate on a closed database.