Skip to content

Postgres Server crash #271

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

Closed
1 of 2 tasks
elanfranconi opened this issue Mar 29, 2025 · 4 comments · Fixed by #273
Closed
1 of 2 tasks

Postgres Server crash #271

elanfranconi opened this issue Mar 29, 2025 · 4 comments · Fixed by #273
Assignees
Labels
bug Something isn't working

Comments

@elanfranconi
Copy link

elanfranconi commented Mar 29, 2025

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Your output:

2025-03-29 16:55:54.250 [info] [Info  - 4:55:54 PM] Server initialized with PID: 9964
2025-03-29 17:57:35.254 [info] Encountered an unexpected error

This is a bug in Postgres Tools, not an error in your code, and we would appreciate it if you could report it along with the following information to help us fixing the issue:

Source Location: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tree-sitter-0.20.10/binding_rust/lib.rs:1168:31
Thread Name: tokio-runtime-worker
Message: range end index 37 out of range for slice of length 26


2025-03-29 17:57:36.024 [info] [Error - 5:57:36 PM] PostgresTools language server closed
2025-03-29 17:57:36.024 [info] [Error - 5:57:36 PM] Server process exited with code 0.

To Reproduce

Unsure, was just typing out some SQL pretty normally.

Expected behavior

N/A

Screenshots

N/A
If applicable, add screenshots to help explain your problem.

System information

Windows VSCode through WSL

Additional context

N/A

@elanfranconi elanfranconi added the bug Something isn't working label Mar 29, 2025
@psteinroe
Copy link
Collaborator

psteinroe commented Mar 29, 2025

thanks for reporting! Would it be possible to share the log output? You should find them here:

  • Linux: ~/.cache/pgt;
  • Windows: C:\Users<UserName>\AppData\Local\supabase-community\pgt\cache
  • macOS: /Users//Library/Caches/dev.supabase-community.pgt

@elanfranconi
Copy link
Author

└─┐pgt_lsp::server::did_change_configuration{}
  └─┐pgt_fs::fs::os::OsFileSystem::open_with_options{path="/redacted/postgrestools.jsonc", options=OpenOptions { read: true, write: false, truncate: false, create: false, create_new: false }}
  ┌─┘
  └─┐pgt_fs::fs::os::OsFile::read_to_string{}
  ┌─┘
  ├─ INFO pgt_lsp::session Configuration loaded successfully from disk.
  ├─ INFO pgt_lsp::session Update workspace settings.
  ├─ INFO pgt_workspace::workspace::server Updating settings in workspace
  ├─ INFO pgt_workspace::workspace::server Updated settings in workspace
  ├─ WARN sqlx_postgres::options::pgpass Failed to open `.pgpass` file: Os { code: 2, kind: NotFound, message: "No such file or directory" }, path=/redacted/.pgpass
  ├─ INFO pgt_workspace::workspace::server Updated Db connection settings
  ├─ INFO pgt_lsp::session Unregister capabilities "workspace/didChangeConfiguration, workspace/didChangeWatchedFiles"
  ├─ INFO pgt_lsp::session Register capabilities "workspace/didChangeConfiguration, workspace/didChangeWatchedFiles"
  ├─ INFO pgt_workspace::workspace::server Pulled 1 diagnostic(s)
  ├─ INFO pgt_workspace::workspace::server Pulled 0 diagnostic(s)
┌─┘
└─┐pgt_lsp::handlers::text_document::did_close{params=DidCloseTextDocumentParams { text_document: TextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/redacted/sql//queries/deleting_duplicates_in_counties.sql", query: None, fragment: None } } }}
┌─┘
└─┐pgt_lsp::server::did_change_configuration{}
  └─┐pgt_fs::fs::os::OsFileSystem::open_with_options{path="/redacted/postgrestools.jsonc", options=OpenOptions { read: true, write: false, truncate: false, create: false, create_new: false }}
  ┌─┘
  └─┐pgt_fs::fs::os::OsFile::read_to_string{}
  ┌─┘
  ├─ INFO pgt_lsp::session Configuration loaded successfully from disk.
  ├─ INFO pgt_lsp::session Update workspace settings.
  ├─ INFO pgt_workspace::workspace::server Updating settings in workspace
  ├─ INFO pgt_workspace::workspace::server Updated settings in workspace
  ├─ WARN sqlx_postgres::options::pgpass Failed to open `.pgpass` file: Os { code: 2, kind: NotFound, message: "No such file or directory" }, path=/redacted/.pgpass
  ├─ INFO pgt_workspace::workspace::server Updated Db connection settings
  ├─ INFO pgt_lsp::session Unregister capabilities "workspace/didChangeConfiguration, workspace/didChangeWatchedFiles"
  ├─ INFO pgt_lsp::session Register capabilities "workspace/didChangeConfiguration, workspace/didChangeWatchedFiles"
  ├─ INFO pgt_workspace::workspace::server Pulled 1 diagnostic(s)
┌─┘
└─┐pgt_lsp::server::did_change_configuration{}
  └─┐pgt_fs::fs::os::OsFileSystem::open_with_options{path="/redacted/postgrestools.jsonc", options=OpenOptions { read: true, write: false, truncate: false, create: false, create_new: false }}
  ┌─┘
  └─┐pgt_fs::fs::os::OsFile::read_to_string{}
  ┌─┘
  ├─ INFO pgt_lsp::session Configuration loaded successfully from disk.
  ├─ INFO pgt_lsp::session Update workspace settings.
  ├─ INFO pgt_workspace::workspace::server Updating settings in workspace
  ├─ INFO pgt_workspace::workspace::server Updated settings in workspace
  ├─ WARN sqlx_postgres::options::pgpass Failed to open `.pgpass` file: Os { code: 2, kind: NotFound, message: "No such file or directory" }, path=/redacted/.pgpass
  ├─ INFO pgt_workspace::workspace::server Updated Db connection settings
  ├─ INFO pgt_lsp::session Unregister capabilities "workspace/didChangeConfiguration, workspace/didChangeWatchedFiles"
  ├─ INFO pgt_lsp::session Register capabilities "workspace/didChangeConfiguration, workspace/didChangeWatchedFiles"
  ├─ INFO pgt_workspace::workspace::server Pulled 1 diagnostic(s)
┌─┘
└─┐pgt_lsp::server::did_change_configuration{}
  └─┐pgt_fs::fs::os::OsFileSystem::open_with_options{path="/redacted/postgrestools.jsonc", options=OpenOptions { read: true, write: false, truncate: false, create: false, create_new: false }}
  ┌─┘
  └─┐pgt_fs::fs::os::OsFile::read_to_string{}
  ┌─┘
  ├─ INFO pgt_lsp::session Configuration loaded successfully from disk.
  ├─ INFO pgt_lsp::session Update workspace settings.
  ├─ INFO pgt_workspace::workspace::server Updating settings in workspace
  ├─ INFO pgt_workspace::workspace::server Updated settings in workspace
  ├─ WARN sqlx_postgres::options::pgpass Failed to open `.pgpass` file: Os { code: 2, kind: NotFound, message: "No such file or directory" }, path=/redacted/.pgpass
  ├─ INFO pgt_workspace::workspace::server Updated Db connection settings
  ├─ INFO pgt_lsp::session Unregister capabilities "workspace/didChangeConfiguration, workspace/didChangeWatchedFiles"
  ├─ INFO pgt_lsp::session Register capabilities "workspace/didChangeConfiguration, workspace/didChangeWatchedFiles"
  ├─ INFO pgt_workspace::workspace::server Pulled 1 diagnostic(s)
┌─┘
└─┐pgt_lsp::handlers::text_document::did_close{params=DidCloseTextDocumentParams { text_document: TextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/redacted/sql/routines.sql", query: None, fragment: None } } }}
┌─┘
└─┐pgt_lsp::handlers::text_document::did_open{params=DidOpenTextDocumentParams { text_document: TextDocumentItem { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/redacted//sql/routines.sql", query: None, fragment: None }, language_id: "sql", version: 29, text: "CREATE COLLATION ignore_accent_case (provider = icu, deterministic = false, locale = 'und-u-ks-level1');\n\n-- CREATE OR REPLACE FUNCTION\n--     add_one(integer)\n-- RETURNS\n--     integer\n-- AS\n--     'add_one.so', 'add_one'\n-- LANGUAGE\n--     C \n-- STRICT;\n\n\nSELECT pwhash, FROM users;" } }}
  ├─ INFO pgt_workspace::workspace::server Opening file: PgTPath { path: "/redacted/sql/routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }
  ├─ INFO pgt_workspace::workspace::server::pg_query adding diagnostics
  ├─ INFO pgt_workspace::workspace::server Pulled 1 diagnostic(s)
┌─┘
└─┐pgt_lsp::handlers::text_document::did_change{params=DidChangeTextDocumentParams { text_document: VersionedTextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/redacted/sql//routines.sql", query: None, fragment: None }, version: 30 }, content_changes: [TextDocumentContentChangeEvent { range: Some(Range { start: Position { line: 13, character: 13 }, end: Position { line: 13, character: 14 } }), range_length: Some(1), text: "" }] }}
  ├─ INFO pgt_workspace::workspace::server Changing file: ChangeFileParams { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, version: 30, changes: [ChangeParams { range: Some(271..272), text: "" }] }
  ├─ DEBUG pgt_workspace::workspace::server Modifying statement: ModifiedStatement { old_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 1 }, old_stmt_text: "SELECT pwhash, FROM users;", new_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 2 }, new_stmt_text: "SELECT pwhash FROM users;", change_range: 13..14, change_text: "" }
  ├─ INFO pgt_workspace::workspace::server Pulled 0 diagnostic(s)
┌─┘
└─┐pgt_lsp::handlers::text_document::did_change{params=DidChangeTextDocumentParams { text_document: VersionedTextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/redacted/sql//routines.sql", query: None, fragment: None }, version: 31 }, content_changes: [TextDocumentContentChangeEvent { range: Some(Range { start: Position { line: 13, character: 13 }, end: Position { line: 13, character: 13 } }), range_length: Some(0), text: "," }] }}
  ├─ INFO pgt_workspace::workspace::server Changing file: ChangeFileParams { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, version: 31, changes: [ChangeParams { range: Some(271..271), text: "," }] }
  ├─ DEBUG pgt_workspace::workspace::server Modifying statement: ModifiedStatement { old_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 2 }, old_stmt_text: "SELECT pwhash FROM users;", new_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 3 }, new_stmt_text: "SELECT pwhash, FROM users;", change_range: 13..13, change_text: "," }
  ├─ INFO pgt_workspace::workspace::server::pg_query adding diagnostics
  ├─ INFO pgt_workspace::workspace::server Pulled 1 diagnostic(s)
┌─┘
└─┐pgt_workspace::workspace::server::get_completions{params=GetCompletionsParams { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, position: 272 }}
  ├─ DEBUG pgt_workspace::workspace::server Getting completions for file PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false } at position 272
  ├─ DEBUG pgt_workspace::workspace::server Found the document. Looking for statement in file PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false } at position: 272
  ├─ DEBUG pgt_workspace::workspace::server Found the statement. We're looking for position 14. Statement Range 258 to 284. Statement: SELECT pwhash, FROM users;
  ├─ DEBUG pgt_workspace::workspace::server Loaded schema cache for completions
┌─┘
└─┐pgt_lsp::handlers::text_document::did_change{params=DidChangeTextDocumentParams { text_document: VersionedTextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/redacted/sql//routines.sql", query: None, fragment: None }, version: 32 }, content_changes: [TextDocumentContentChangeEvent { range: Some(Range { start: Position { line: 13, character: 14 }, end: Position { line: 13, character: 14 } }), range_length: Some(0), text: " " }] }}
  ├─ INFO pgt_workspace::workspace::server Changing file: ChangeFileParams { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, version: 32, changes: [ChangeParams { range: Some(272..272), text: " " }] }
  ├─ DEBUG pgt_workspace::workspace::server Modifying statement: ModifiedStatement { old_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 3 }, old_stmt_text: "SELECT pwhash, FROM users;", new_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 4 }, new_stmt_text: "SELECT pwhash,  FROM users;", change_range: 14..14, change_text: " " }
  ├─ INFO pgt_workspace::workspace::server::pg_query adding diagnostics
  ├─ INFO pgt_workspace::workspace::server Pulled 1 diagnostic(s)
┌─┘
└─┐pgt_workspace::workspace::server::get_completions{params=GetCompletionsParams { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, position: 273 }}
  ├─ DEBUG pgt_workspace::workspace::server Getting completions for file PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false } at position 273
  ├─ DEBUG pgt_workspace::workspace::server Found the document. Looking for statement in file PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false } at position: 273
  ├─ DEBUG pgt_workspace::workspace::server Found the statement. We're looking for position 15. Statement Range 258 to 285. Statement: SELECT pwhash,  FROM users;
  ├─ DEBUG pgt_workspace::workspace::server Loaded schema cache for completions
┌─┘
└─┐pgt_lsp::handlers::text_document::did_change{params=DidChangeTextDocumentParams { text_document: VersionedTextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/redacted/sql//routines.sql", query: None, fragment: None }, version: 33 }, content_changes: [TextDocumentContentChangeEvent { range: Some(Range { start: Position { line: 13, character: 15 }, end: Position { line: 13, character: 15 } }), range_length: Some(0), text: "county_name" }] }}
  ├─ INFO pgt_workspace::workspace::server Changing file: ChangeFileParams { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, version: 33, changes: [ChangeParams { range: Some(273..273), text: "county_name" }] }
  ├─ DEBUG pgt_workspace::workspace::server Modifying statement: ModifiedStatement { old_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 4 }, old_stmt_text: "SELECT pwhash,  FROM users;", new_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 5 }, new_stmt_text: "SELECT pwhash, county_name FROM users;", change_range: 15..15, change_text: "county_name" }
  ├─ INFO pgt_workspace::workspace::server Pulled 1 diagnostic(s)
┌─┘
└─┐pgt_lsp::handlers::text_document::did_change{params=DidChangeTextDocumentParams { text_document: VersionedTextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/redacted/sql//routines.sql", query: None, fragment: None }, version: 34 }, content_changes: [TextDocumentContentChangeEvent { range: Some(Range { start: Position { line: 13, character: 13 }, end: Position { line: 13, character: 26 } }), range_length: Some(13), text: "" }] }}
  ├─ INFO pgt_workspace::workspace::server Changing file: ChangeFileParams { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, version: 34, changes: [ChangeParams { range: Some(271..284), text: "" }] }
  ├─ DEBUG pgt_workspace::workspace::server Modifying statement: ModifiedStatement { old_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 5 }, old_stmt_text: "SELECT pwhash, county_name FROM users;", new_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 6 }, new_stmt_text: "SELECT pwhash FROM users;", change_range: 13..26, change_text: "" }
  ├─ INFO pgt_workspace::workspace::server Pulled 0 diagnostic(s)
┌─┘
└─┐pgt_lsp::handlers::text_document::did_change{params=DidChangeTextDocumentParams { text_document: VersionedTextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/redacted/sql//routines.sql", query: None, fragment: None }, version: 35 }, content_changes: [TextDocumentContentChangeEvent { range: Some(Range { start: Position { line: 13, character: 13 }, end: Position { line: 13, character: 13 } }), range_length: Some(0), text: "," }] }}
  ├─ INFO pgt_workspace::workspace::server Changing file: ChangeFileParams { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, version: 35, changes: [ChangeParams { range: Some(271..271), text: "," }] }
  ├─ DEBUG pgt_workspace::workspace::server Modifying statement: ModifiedStatement { old_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 6 }, old_stmt_text: "SELECT pwhash FROM users;", new_stmt: Statement { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, id: 7 }, new_stmt_text: "SELECT pwhash, FROM users;", change_range: 13..13, change_text: "," }
  ├─ INFO pgt_workspace::workspace::server::pg_query adding diagnostics
  ├─ INFO pgt_workspace::workspace::server Pulled 1 diagnostic(s)
┌─┘
└─┐pgt_workspace::workspace::server::get_completions{params=GetCompletionsParams { path: PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false }, position: 272 }}
  ├─ DEBUG pgt_workspace::workspace::server Getting completions for file PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false } at position 272
  ├─ DEBUG pgt_workspace::workspace::server Found the document. Looking for statement in file PgTPath { path: "/redacted/sql//routines.sql", kind: FileKinds(BitFlags<FileKind>(0b1000, Handleable)), was_written: false } at position: 272
  ├─ DEBUG pgt_workspace::workspace::server Found the statement. We're looking for position 14. Statement Range 258 to 284. Statement: SELECT pwhash, FROM users;
  ├─ DEBUG pgt_workspace::workspace::server Loaded schema cache for completions
  ├─ ERROR pgt_cli::panic Encountered an unexpected error
  │ 
  │ This is a bug in Postgres Tools, not an error in your code, and we would appreciate it if you could report it along with the following information to help us fixing the issue:
  │ 
  │ Source Location: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tree-sitter-0.20.10/binding_rust/lib.rs:1168:31
  │ Thread Name: tokio-runtime-worker
  │ Message: range end index 37 out of range for slice of length 26
  │ 
┌─┘
INFO pgt_cli::commands::daemon Received shutdown signal
┘

@psteinroe
Copy link
Collaborator

psteinroe commented Mar 29, 2025

@juleswritescode this looks like an out of bounds in completions

that's on me - the input we pass to the completions is out of sync.

@psteinroe psteinroe self-assigned this Mar 29, 2025
@psteinroe
Copy link
Collaborator

I am able to repro @elanfranconi, thanks for providing the logs! will fix this asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants