Skip to content
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

Uds support #3259

Merged
merged 5 commits into from Aug 11, 2020
Merged

Uds support #3259

merged 5 commits into from Aug 11, 2020

Conversation

timsuchanek
Copy link
Contributor

Closes #3092

Copy link
Member

@Jolg42 Jolg42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice!

@@ -166,6 +172,12 @@ export class NodeEngine {
)
this.engineEndpoint = engineEndpoint

if (useUds && process.platform !== 'win32') {
this.socketPath = `/tmp/prisma-${getRandomString()}.sock`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the chances that the filesystem refuse access to /tmp/ or if it's read only? I guess the socket would not initialize?

Should we check that first maybe like this?

try {
	// R_OK | Flag indicating that the file can be read by the calling process.
	// W_OK | Flag indicating that the file can be written by the calling process.
    fs.accessSync(path.dirname(this.socketPath), fs.constants.R_OK | fs.constants.W_OK)
}
catch (err) {
    // err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aware of any case, in which /tmp is not writable.
I would personally keep it simple for now.

if (!this.useUds) {
env.PORT = String(this.port)
} else {
debug(`port: ${this.port}`)
Copy link
Member

@Jolg42 Jolg42 Aug 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the debug only for useUds is truthy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops that's wrong, will fix

src/packages/engine-core/src/NodeEngine.ts Show resolved Hide resolved
src/packages/engine-core/src/undici.ts Show resolved Hide resolved
@Jolg42
Copy link
Member

Jolg42 commented Aug 11, 2020

Also it looks like test failed in CI

@timsuchanek
Copy link
Contributor Author

Also it looks like test failed in CI

Yep, that's why I'm setting up a Linux machine right now, because I can't reproduce the failing tests on Mac.

@timsuchanek
Copy link
Contributor Author

UDS can be enabled with

new PrismaClient({ __internal: { useUds: true } })

@timsuchanek timsuchanek merged commit 3a09e37 into master Aug 11, 2020
@timsuchanek timsuchanek deleted the uds-support branch August 11, 2020 15:46
@pantharshit00
Copy link
Contributor

I tried it out and looks like it is working well 💯
image

image

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.

Switch Client to use Unix Domain Sockets
3 participants