Repository navigation
Open
RobertCraigie/prisma-client-py
#508Labels
bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.tech/typescriptIssue for tech TypeScript.topic: prisma generateCLI: prisma generatetopic: windows
Milestone
Description
Bug description
On windows, if generator errors are not explicitly caught and returned (through JSONRPC) then the CLI process exits with 0 regardless of the state of the generator process and does not display any error message.
This behaviour is different on UNIX platforms, the Prisma CLI will exit with a non-zero code when a generator process errors.
How to reproduce
Run prisma generate:
(.venv) PS C:\Users\robert> prisma generate
Prisma schema loaded from schema.prisma
(.venv) PS C:\Users\robert> echo $LASTEXITCODE
0
Expand to show DEBUG logs
(.venv) PS C:\Users\robert> prisma generate
prisma:tryLoadEnv Environment variables not found at null +0ms
prisma:tryLoadEnv Environment variables not found at undefined +1ms
prisma:tryLoadEnv No Environment variables loaded +0ms
prisma:engines binaries to download query-engine, migration-engine, introspection-engine, prisma-fmt +0ms
prisma:download Using env var PRISMA_QUERY_ENGINE_BINARY for binary query-engine, which points to C:\Users\rober\AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-query-engine-windows.exe +0ms
prisma:download Using env var PRISMA_MIGRATION_ENGINE_BINARY for binary migration-engine, which points to C:\Users\rober\AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-migration-engine-windows.exe +0ms
prisma:download Using env var PRISMA_INTROSPECTION_ENGINE_BINARY for binary introspection-engine, which points to C:\Users\rober\AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-introspection-engine-windows.exe +0ms
prisma:download Using env var PRISMA_FMT_BINARY for binary prisma-fmt, which points to C:\Users\rober\AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-prisma-fmt-windows.exe +1ms
Prisma schema loaded from schema.prisma
prisma:download Using env var PRISMA_QUERY_ENGINE_BINARY for binary query-engine, which points to C:\Users\rober\AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-query-engine-windows.exe +0ms
prisma:getConfig Using CLI Query Engine (Binary) at: C:\Users\rober\AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-query-engine-windows.exe +0ms
prisma:getDMMF Using CLI Query Engine (Binary) at: C:\Users\rober\AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-query-engine-windows.exe +0ms
prisma:getGenerators neededVersions {} +0ms
prisma:GeneratorProcess Traceback (most recent call last): +0ms
prisma:GeneratorProcess File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main +0ms
prisma:GeneratorProcess return _run_code(code, main_globals, None, +1ms
prisma:GeneratorProcess File "C:\Python39\lib\runpy.py", line 87, in _run_code +0ms
prisma:GeneratorProcess exec(code, run_globals) +1ms
prisma:GeneratorProcess File "C:\Users\rober\.venv\Scripts\prisma-client-py.exe\__main__.py", line 7, in <module> +0ms
prisma:GeneratorProcess File "c:\users\rober\.venv\lib\site-packages\prisma\cli\cli.py", line 50, in main +1ms
prisma:GeneratorProcess prisma.invoke() +0ms
prisma:GeneratorProcess File "c:\users\rober\.venv\lib\site-packages\prisma\cli\prisma.py", line 93, in invoke +0ms
prisma:GeneratorProcess generator.run(request.params) +1ms
prisma:GeneratorProcess File "c:\users\rober\.venv\lib\site-packages\prisma\generator\generator.py", line 71, in run +0ms
prisma:GeneratorProcess render_template(rootdir, name, params) +0ms
prisma:GeneratorProcess File "c:\users\rober\.venv\lib\site-packages\prisma\generator\generator.py", line 118, in render_template +1ms
prisma:GeneratorProcess output = template.render(**params) +0ms
prisma:GeneratorProcess File "c:\users\rober\.venv\lib\site-packages\jinja2\environment.py", line 1291, in render +0ms
prisma:GeneratorProcess self.environment.handle_exception() +1ms
prisma:GeneratorProcess File "c:\users\rober\.venv\lib\site-packages\jinja2\environment.py", line 925, in handle_exception +0ms
prisma:GeneratorProcess raise rewrite_traceback_stack(source=source) +0ms
prisma:GeneratorProcess File "c:\users\rober\.venv\lib\site-packages\prisma\generator\templates\types.py.jinja", line 318, in top-level template code +1ms
prisma:GeneratorProcess {{' '}}{{ field.name }}: {{ field.maybe_optional(field.get_update_input_type()) }} +0ms
prisma:GeneratorProcess File "c:\users\rober\.venv\lib\site-packages\prisma\generator\models.py", line 506, in get_update_input_type +1ms
prisma:GeneratorProcess raise NotImplementedError( +0ms
prisma:GeneratorProcess NotImplementedError: Atomic updates for scalar list types not implemented yet. +0ms
Expected behavior
An error message should be displayed and the process should exit with a non-zero code.
Prisma information
datasource db {
provider = "postgres"
url = env("DATABASE_URL")
}
generator db {
provider = "prisma-client-py"
interface = "asyncio"
recursive_type_depth = -1
}
model User {
id String @id @default(cuid())
name String
numbers Int[]
}Environment & setup
- OS: Windows 10
- Database: PostgreSQL
- Node.js version: N/A
Prisma Version
prisma : 3.4.0
@prisma/client : Not found
Current platform : windows
Query Engine (Binary) : query-engine 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-query-engine-windows.exe, resolved by PRISMA_QUERY_ENGINE_BINARY)
Migration Engine : migration-engine-cli 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-migration-engine-windows.exe, resolved by PRISMA_MIGRATION_ENGINE_BINARY)
Introspection Engine : introspection-core 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-introspection-engine-windows.exe, resolved by PRISMA_INTROSPECTION_ENGINE_BINARY)
Format Binary : prisma-fmt 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at AppData\Local\Temp\prisma\binaries\engines\1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85\prisma-prisma-fmt-windows.exe, resolved by PRISMA_FMT_BINARY)
Default Engines Hash : 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.tech/typescriptIssue for tech TypeScript.topic: prisma generateCLI: prisma generatetopic: windows
Activity
[-]Generator exit codes and errors are not propagated on windows[/-][+]Generator exit codes and error messages are not propagated on windows[/+]janpio commentedon Nov 19, 2021
Does this apply to all generators or "just" to custom generators?
RobertCraigie commentedon Nov 19, 2021
I'm not sure, I did not test it with other generators and do not have access to a windows machine at the moment. Will update as soon as possible.
Although I am fairly certain that this issue won't occur with any JavaScript based generators as errors are explicitly sent back to the Prisma CLI through JSON-RPC (the prisma-client-py JSON-RPC implementation does not do this yet) and a while ago I was experimenting with generator exit codes and found that if the process crashed before starting the JSON-RPC generation loop then the error was correctly propagated.
The example I used above crashes during the
generatecall of the JSON-RPC generation loop.I could be totally misremembering though, it has been a while since I experimented with Prisma on windows.
RobertCraigie commentedon Nov 22, 2021
@janpio Here's a minimal reproduction using a custom TS generator:
https://github.com/RobertCraigie/prisma-reproduction-10270
refactor(generator): send explicit errors through JSONRPC
aqrln commentedon Oct 4, 2022
Reopening because, if my understanding of the issue is correct, the issue is still there in Prisma even if Prisma Client Python works around it now.
RobertCraigie commentedon Oct 5, 2022
Ah yeah you're right, thanks!
I didn't realise GitHub would automatically close issues across repositories when they're not in the same org.