Skip to content

Fix crash caused by DuckDB connection error #745

Closed
@tconbeer

Description

When opening the same db in two terminals:

~/open/harlequin fix/infinity-timestamps ≢  ~3  3.9 ❯ make serve
textual run --dev -c harlequin -P dev -f . f1.db
╭─ DuckDB couldn't connect to your database. ──────────────────────────────────────────────────────────────────────────╮
│ IO Error: Could not set lock on file "/home/tco/open/harlequin/f1.db": Conflicting lock is held in                   │
│ /home/tco/.local/share/uv/python/cpython-3.9.20-linux-x86_64-gnu/bin/python3.9 (PID 26697). See also                 │
│ https://duckdb.org/docs/connect/concurrency                                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────╮
│ /home/tco/open/harlequin/src/harlequin/components/code_editor.py:224 in on_mount                                     │
│                                                                                                                      │
│   221 │   async def on_mount(self) -> None:                                                                          │
│   222 │   │   if self.startup_cache is not None:                                                                     │
│   223 │   │   │   for _i, buffer in enumerate(self.startup_cache.buffers):                                           │
│ ❱ 224 │   │   │   │   await self.action_new_buffer(state=buffer)                                                     │
│   225 │   │   │   │   # we can't load the focus state here, since Tabs                                               │
│   226 │   │   │   │   # really wants to activate the first tab when it's                                             │
│   227 │   │   │   │   # mounted                                                                                      │
│                                                                                                                      │
│ ╭───────────────────────────────────────────────── locals ─────────────────────────────────────────────────╮         │
│ │     _i = 0                                                                                               │         │
│ │ buffer = BufferState(                                                                                    │         │
│ │          │   selection=Selection(start=(3, 39), end=(3, 39)),                                            │         │
│ │          │   text="-- select current_date, current_timestamp::timestamp, '2025-02-05 22:07:42.90456"+175 │         │
│ │          )                                                                                               │         │
│ │   self = EditorCollection()                                                                              │         │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯         │
│                                                                                                                      │
│ /home/tco/open/harlequin/src/harlequin/components/code_editor.py:275 in action_new_buffer                            │
│                                                                                                                      │
│   272 │   │   │   editor,                                                                                            │
│   273 │   │   │   id=new_tab_id,                                                                                     │
│   274 │   │   )                                                                                                      │
│ ❱ 275 │   │   await self.add_pane(pane)                                                                              │
│   276 │   │   if state is not None:                                                                                  │
│   277 │   │   │   editor.selection = state.selection                                                                 │
│   278 │   │   else:                                                                                                  │
│                                                                                                                      │
│ ╭─────────────────────────────────────────────────── locals ───────────────────────────────────────────────────╮     │
│ │     editor = CodeEditor(id='buffer-1')                                                                       │     │
│ │ new_tab_id = 'tab-1'                                                                                         │     │
│ │       pane = TabPane(id='tab-1')                                                                             │     │
│ │       self = EditorCollection()                                                                              │     │
│ │      state = BufferState(                                                                                    │     │
│ │              │   selection=Selection(start=(3, 39), end=(3, 39)),                                            │     │
│ │              │   text="-- select current_date, current_timestamp::timestamp, '2025-02-05 22:07:42.90456"+175 │     │
│ │              )                                                                                               │     │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯     │
│                                                                                                                      │
│ /home/tco/.cache/pypoetry/virtualenvs/harlequin-4LobG8aN-py3.9/lib/python3.9/site-packages/textual/widgets/_tabbed_c │
│ ontent.py:441 in add_pane                                                                                            │
│                                                                                                                      │
│   438 │   │   assert pane.id is not None                                                                             │
│   439 │   │   pane.display = False                                                                                   │
│   440 │   │   return AwaitComplete(                                                                                  │
│ ❱ 441 │   │   │   tabs.add_tab(                                                                                      │
│   442 │   │   │   │   ContentTab(pane._title, pane.id),                                                              │
│   443 │   │   │   │   before=before if before is None else ContentTab.add_prefix(before),                            │
│   444 │   │   │   │   after=after if after is None else ContentTab.add_prefix(after),                                │
│                                                                                                                      │
│ ╭─────────── locals ───────────╮                                                                                     │
│ │  after = None                │                                                                                     │
│ │ before = None                │                                                                                     │
│ │   pane = TabPane(id='tab-1') │                                                                                     │
│ │   self = EditorCollection()  │                                                                                     │
│ │   tabs = ContentTabs()       │                                                                                     │
│ ╰──────────────────────────────╯                                                                                     │
│                                                                                                                      │
│ /home/tco/.cache/pypoetry/virtualenvs/harlequin-4LobG8aN-py3.9/lib/python3.9/site-packages/textual/widgets/_tabs.py: │
│ 492 in add_tab                                                                                                       │
│                                                                                                                      │
│   489 │   │   │   else self._auto_tab_id(tab)                                                                        │
│   490 │   │   )                                                                                                      │
│   491 │   │                                                                                                          │
│ ❱ 492 │   │   mount_await = self.query_one("#tabs-list").mount(                                                      │
│   493 │   │   │   tab_widget, before=before, after=after                                                             │
│   494 │   │   )                                                                                                      │
│   495                                                                                                                │
│                                                                                                                      │
│ ╭───────────────────── locals ──────────────────────╮                                                                │
│ │      after = None                                 │                                                                │
│ │     before = None                                 │                                                                │
│ │ from_empty = True                                 │                                                                │
│ │       self = ContentTabs()                        │                                                                │
│ │        tab = ContentTab(id='--content-tab-tab-1') │                                                                │
│ │ tab_widget = ContentTab(id='--content-tab-tab-1') │                                                                │
│ ╰───────────────────────────────────────────────────╯                                                                │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
NoMatches: No nodes match '#tabs-list' on ContentTabs()

NOTE: 2 errors shown above.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions