`introspect` fails on SQLite
See original GitHub issueprisma/schema.prisma:
datasource db {
provider = "sqlite"
url = "sqlite:./../1093.db"
}
generator client {
provider = "prisma-client-js"
}
Zipped 1093.db file to put in root of project:
1093.zip
(originally via https://github.com/prisma/prisma2/issues/1093#issue-535203619)
When I run prisma2 introspect I get this:
C:\Users\Jan\Documents\throwaway\1093>prisma2 introspect
Introspecting based on datasource defined in prisma\schema.prisma …
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
at doWrite (_stream_writable.js:413:19)
at writeOrBuffer (_stream_writable.js:401:5)
at Socket.Writable.write (_stream_writable.js:301:11)
at C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\build\index.js:2:884310
at new Promise (<anonymous>)
at IntrospectionEngine.<anonymous> (C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\build\index.js:2:883015)
at Generator.next (<anonymous>)
at fulfilled (C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\build\index.js:2:877318)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
ERROR Oops, an unexpected error occured!
[src\libcore\option.rs:1188:5] to
More info:
C:\Users\Jan\Documents\throwaway\1093>set DEBUG=*
C:\Users\Jan\Documents\throwaway\1093>prisma2 introspect
prisma .env loaded from ./prisma/.env +0ms
getos { platform: 'win32', libssl: undefined } +0ms
cleanupCache Error: ENOENT: no such file or directory, scandir 'C:\Users\Jan\AppData\Roaming\Prisma\alpha' +0ms
download Setting binary path for query-engine windows to C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\query-engine-windows.exe +0ms
download Setting binary path for migration-engine windows to C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\migration-engine-windows.exe +1ms
download Setting binary path for introspection-engine windows to C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\introspection-engine-windows.exe +1ms
Introspecting based on datasource defined in prisma\schema.prisma …
getos { platform: 'win32', libssl: undefined } +47ms
IntrospectionEngine:rpc starting introspection engine with binary: C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\introspection-engine-windows.exe +0ms
IntrospectionEngine:rpc SENDING RPC CALL {"id":1,"jsonrpc":"2.0","method":"introspect","params":[{"schema":"// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ndatasource db {\n provider = \"sqlite\"\n
url = \"sqlite:./../1093.db\"\n}\n\ngenerator client {\n provider = \"prisma-client-js\"\n}\n"}]} +14ms
IntrospectionEngine:stderr {"is_panic":true,"message":"[src\\libcore\\option.rs:1188:5] to","backtrace":" 0: backtrace::backtrace::trace\n 1: backtrace::capture::Backtrace::new\n 2: user_facing_errors::Error::new_in_panic_hook\n 3: user_facing_errors::panic_hook::set_panic_hook::{{closure}}\n 4: std::panicking::rust_panic_with_hook\n at src\\libstd/panicking.rs:475\n 5: rust_begin_unwind\n at src\\libstd/panicking.rs:375\n 6: core::panicking::panic_fmt\n at src\\libcore/panicking.rs:84\n 7: core::option::expect_failed\n at src\\libcore/option.rs:1188\n 8: sql_schema_describer::sqlite::SqlSchemaDescriber::get_table::{{closure}}\n 9: <std::future::GenFuture<T> as core::future::future::Future>::poll\n 10: std::future::poll_with_tls_context\n 11: <std::future::GenFuture<T> as core::future::future::Future>::poll\n 12: <std::future::GenFuture<T> as core::future::future::Future>::poll\n 13: <futures_util::compat::compat03as01::Compat<Fut> as futures::future::Future>::poll\n 14: <futures::future::map::Map<A,F> as futures::future::Future>::poll\n 15: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll\n 16: <futures::future::either::Either<A,B> as futures::future::Future>::poll\n 17: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll\n 18: futures::future::chain::Chain<A,B,C>::poll\n 19: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll\n 20: <futures::future::either::Either<A,B> as futures::future::Future>::poll\n 21: <futures::future::map::Map<A,F> as futures::future::Future>::poll\n 22: <futures::future::either::Either<A,B> as futures::future::Future>::poll\n 23: <futures::future::map::Map<A,F> as futures::future::Future>::poll\n 24: futures::task_impl::std::set\n 25: <futures_util::compat::compat01as03::Compat01As03<Fut> as core::future::future::Future>::poll\n 26: <std::future::GenFuture<T> as core::future::future::Future>::poll\n 27: tokio::runtime::enter::Enter::block_on\n 28: tokio::runtime::thread_pool::ThreadPool::block_on\n 29: tokio::runtime::context::enter\n 30: tokio::runtime::handle::Handle::enter\n 31: introspection_engine::main\n 32: std::rt::lang_start::{{closure}}\n 33: std::rt::lang_start_internal::{{closure}}\n at src\\libstd/rt.rs:52\n std::panicking::try::do_call\n at src\\libstd/panicking.rs:292\n 34: __rust_maybe_catch_panic\n at src\\libpanic_unwind/lib.rs:78\n 35: std::panicking::try\n at src\\libstd/panicking.rs:270\n std::panic::catch_unwind\n
at src\\libstd/panic.rs:394\n std::rt::lang_start_internal\n at src\\libstd/rt.rs:51\n 36: main\n 37: _tmainCRTStartup\n 38: mainCRTStartup\n 39: sqlite3GenerateConstraintChecks\n 40: sqlite3GenerateConstraintChecks\n"} +0ms
IntrospectionEngine:rpc SENDING RPC CALL {"id":2,"jsonrpc":"2.0","method":"getDatabaseDescription","params":[{"schema":"// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ndatasource db {\n provider = \"sqlite\"\n url = \"sqlite:./../1093.db\"\n}\n\ngenerator client {\n provider = \"prisma-client-js\"\n}\n"}]} +92ms
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
at doWrite (_stream_writable.js:413:19)
at writeOrBuffer (_stream_writable.js:401:5)
at Socket.Writable.write (_stream_writable.js:301:11)
at C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\build\index.js:2:884310
at new Promise (<anonymous>)
at IntrospectionEngine.<anonymous> (C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\build\index.js:2:883015)
at Generator.next (<anonymous>)
at fulfilled (C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\build\index.js:2:877318)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
IntrospectionEngine:stdin Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
IntrospectionEngine:stdin at doWrite (_stream_writable.js:413:19)
IntrospectionEngine:stdin at writeOrBuffer (_stream_writable.js:401:5)
IntrospectionEngine:stdin at Socket.Writable.write (_stream_writable.js:301:11)
IntrospectionEngine:stdin at C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\build\index.js:2:884310
IntrospectionEngine:stdin at new Promise (<anonymous>)
IntrospectionEngine:stdin at IntrospectionEngine.<anonymous> (C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\build\index.js:2:883015)
IntrospectionEngine:stdin at Generator.next (<anonymous>)
IntrospectionEngine:stdin at fulfilled (C:\ProgramData\nvm\v12.6.0\node_modules\prisma2\build\index.js:2:877318)
IntrospectionEngine:stdin at processTicksAndRejections (internal/process/task_queues.js:85:5) +0ms
ERROR Oops, an unexpected error occured!
[src\libcore\option.rs:1188:5] to
(preview 22 on Windows, but Harshit could reproduce on other platform)
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
SQLite schema introspection implementation struggles with ...
Here's a test that fails on SQLite and passes on MySQL... fun times. I've change around the logic to only trim the value...
Read more >What is introspection? (Reference) - Prisma
This is most commonly the case when you're not using Prisma Migrate but perform schema migrations using plain SQL or another migration tool....
Read more >PyCharm fails to connect to SQLite: SQLITE_BUSY, (database ...
This happens when the application isn't running, so nothing is currently connected to the db. EDIT: I've learned that the problem only exists ......
Read more >The Virtual Table Mechanism Of SQLite
A full-text search interface; Spatial indices using R-Trees; Introspect the ... The virtual table implementation may pass error message text to the core...
Read more >Fix the SQLite "attempt to write a readonly database" error
If you're encountering "General error - 8 attempt to write a readonly database" when working with SQLite, and confused because the write ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This was caused by a shortcut in the Sqlite foreign key definition btw.
They allow you to write:
userid Int References userinstead ofuserid Int References user(id)Unfortunately the meta information calls then don’t automatically provide the Information about the referenced column which caused the crash. This is now being handled.
I think “Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed” is a follow up error when the Engine crashes. We might want to handle that better - you have a nice reproduction here 😉