Skip to content

fix(se): handle EOF in stdin - #5486

Merged
aqrln merged 1 commit into
mainfrom
push-ypyyovwotpsl
Jun 18, 2025
Merged

fix(se): handle EOF in stdin#5486
aqrln merged 1 commit into
mainfrom
push-ypyyovwotpsl

Conversation

@aqrln

@aqrln aqrln commented Jun 17, 2025

Copy link
Copy Markdown
Member

Turns out we didn't actually exit when we hit EOF in stdin in the schema engine's RPC server, and just kept sleeping forever instead.

This commit changes that to drain the client_adapter.request_receiver queue and exit the loop when EOF is encountered.

This is important because on Windows we can't use signals for graceful shutdown, so we should do that by closing the stdin pipe.

Ref: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows

Turns out we didn't actually exit when we hit EOF in stdin in the schema
engine's RPC server, and just kept sleeping forever instead.

This commit changes that to drain the `client_adapter.request_receiver`
queue and exit the loop when EOF is encountered.

This is important because on Windows we can't use signals for graceful
shutdown, so we should do that by closing the stdin pipe.

Ref: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
@aqrln aqrln added this to the 6.10.1 milestone Jun 17, 2025
@codspeed-hq

codspeed-hq Bot commented Jun 17, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #5486 will not alter performance

Comparing push-ypyyovwotpsl (3b32fe7) with main (aee10d5)

Summary

✅ 11 untouched benchmarks

aqrln added a commit to prisma/prisma that referenced this pull request Jun 17, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
@github-actions

Copy link
Copy Markdown
Contributor

WASM Query Engine file Size

Engine This PR Base branch Diff
Postgres 2.185MiB 2.185MiB 0.000B
Postgres (gzip) 875.267KiB 875.266KiB 1.000B
Mysql 2.150MiB 2.150MiB 0.000B
Mysql (gzip) 860.268KiB 860.267KiB 1.000B
Sqlite 2.059MiB 2.059MiB 0.000B
Sqlite (gzip) 825.674KiB 825.674KiB 0.000B
SQL Server 2.115MiB 2.115MiB 0.000B
SQL Server (gzip) 848.864KiB 848.864KiB 0.000B

aqrln added a commit to prisma/prisma that referenced this pull request Jun 17, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the
graceful shutdown code. We should trigger the graceful shutdown
by closing stdin instead.

Depends on <prisma/prisma-engines#5486>.

Closes: https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
@aqrln
aqrln merged commit 09706cd into main Jun 18, 2025
167 checks passed
@aqrln
aqrln deleted the push-ypyyovwotpsl branch June 18, 2025 15:15
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the graceful
shutdown code. We should trigger the graceful shutdown by closing stdin
instead.

Depends on <prisma/prisma-engines#5486>.

Closes:
https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit that referenced this pull request Jun 18, 2025
Turns out we didn't actually exit when we hit EOF in stdin in the schema
engine's RPC server, and just kept sleeping forever instead.

This commit changes that to drain the `client_adapter.request_receiver`
queue and exit the loop when EOF is encountered.

This is important because on Windows we can't use signals for graceful
shutdown, so we should do that by closing the stdin pipe.

Ref:
https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
aqrln added a commit to prisma/prisma that referenced this pull request Jun 18, 2025
Windows doesn't have signals, so calling `this.child?.kill()`
immediately terminates the child process without running the graceful
shutdown code. We should trigger the graceful shutdown by closing stdin
instead.

Depends on <prisma/prisma-engines#5486>.

Closes:
https://linear.app/prisma-company/issue/ORM-1093/schema-engine-termination-on-windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants