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

spawn: query engine errored #1128

Closed
RalphLincoln opened this issue Dec 17, 2023 · 15 comments · Fixed by #1136
Closed

spawn: query engine errored #1128

RalphLincoln opened this issue Dec 17, 2023 · 15 comments · Fixed by #1136

Comments

@RalphLincoln
Copy link

RalphLincoln commented Dec 17, 2023

spawn: query engine errored: expected value at line 1 column 1

This error occurs due to this.

if clientErr := client.Prisma.Connect(); clientErr != nil {
		logs.Error().Msgf("Failed to create prisma client due to error. Error=(%+v)", clientErr)
		fmt.Printf("Failed to create prisma client due to error. Error=(%+v)", clientErr)

		return c.Status(fiber.StatusInternalServerError).JSON(consumeruser.AllLocationConsumerResponse{
			Message:   "Failed to get Locations",
			Status:    false,
			Locations: []consumeruser.SmallLocation{},
		})
	}

@steebchen
Copy link
Owner

Can you please set the env var PRISMA_CLIENT_GO_LOG=debug and share the full logs when this error occurs. Also helpful might be your prisma.schema (the top config part) and any more info, like does this always happen on a specific OS or cloud, does it happen only sometimes, etc.

@RalphLincoln
Copy link
Author

RalphLincoln commented Dec 17, 2023

Ok.....this is the full error

[prisma-client-go] DEBUG: 2023/12/17 12:12:51.690336 ensure query engine binary...
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.690697 temp dir: /var/folders/3c/8j5_3l6d7q7320jx2p8424mr0000gn/T/
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.690706 global cache dir: /Users/ikennaalaneme/Library/Caches
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.690710 checking for local query engine `prisma-query-engine-darwin-arm64` or `prisma-query-engine-darwin-arm64`
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.690728 checking for global query engine `/var/folders/3c/8j5_3l6d7q7320jx2p8424mr0000gn/T/prisma/binaries/engines/79fb5193cf0a8fdbef536e4b4a159cad677ab1b9/unpacked/v2/prisma-query-engine-darwin-arm64` or `/var/folders/3c/8j5_3l6d7q7320jx2p8424mr0000gn/T/prisma/binaries/engines/79fb5193cf0a8fdbef536e4b4a159cad677ab1b9/unpacked/v2/prisma-query-engine-darwin-arm64`
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.690730 checking for cached query engine `/Users/ikennaalaneme/Library/Caches/prisma/binaries/cli/5.7.0/79fb5193cf0a8fdbef536e4b4a159cad677ab1b9/prisma-query-engine-darwin-arm64` or `/Users/ikennaalaneme/Library/Caches/prisma/binaries/cli/5.7.0/79fb5193cf0a8fdbef536e4b4a159cad677ab1b9/prisma-query-engine-darwin-arm64`
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.690870 query engine found in cache path: /Users/ikennaalaneme/Library/Caches/prisma/binaries/cli/5.7.0/79fb5193cf0a8fdbef536e4b4a159cad677ab1b9/prisma-query-engine-darwin-arm64 &{name:prisma-query-engine-darwin-arm64 size:17499520 mode:493 modTime:{wall:661115539 ext:63837751697 loc:0x1023cf8a0} sys:{Dev:16777232 Mode:33261 Nlink:1 Ino:91675002 Uid:501 Gid:20 Rdev:0 Pad_cgo_0:[0 0 0 0] Atimespec:{Sec:1702811505 Nsec:731589673} Mtimespec:{Sec:1702154897 Nsec:661115539} Ctimespec:{Sec:1702154897 Nsec:661115539} Birthtimespec:{Sec:1702154897 Nsec:643338101} Size:17499520 Blocks:34184 Blksize:4096 Flags:0 Gen:0 Lspare:0 Qspare:[0 0]}}
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.704287 version check took 13.321125ms
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.704349 using query engine at /Users/ikennaalaneme/Library/Caches/prisma/binaries/cli/5.7.0/79fb5193cf0a8fdbef536e4b4a159cad677ab1b9/prisma-query-engine-darwin-arm64
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.704357 ensure query engine took 13.661334ms
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.708030 running query-engine on port 55680
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.708227 datasources: [{"name":"db","url":"mongodb+srv://<user>:<password>@cluster0.rre55.mongodb.net/test-flashboord?retryWrites=true\u0026w=majority"}]
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.708239 starting engine...
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.709510 connecting to engine...
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.709555 prisma engine payload: `{}`
[prisma-client-go] DEBUG: 2023/12/17 12:12:51.710433 could not connect; retrying...
{"timestamp":"2023-12-17T11:12:51.714163Z","level":"INFO","fields":{"message":"Encountered error during initialization:"},"target":"query_engine"}
2023/12/17 12:12:51 expected value at line 1 column 1
Failed to create prisma client due to error. Error=(spawn: query engine errored: expected value at line 1 column 1)

@RalphLincoln
Copy link
Author

RalphLincoln commented Dec 17, 2023

Anytime I run go run github.com/steebchen/prisma-client-go generate or go run github.com/steebchen/prisma-client-go db push It keeps using data from my os(mac os) cache

[prisma-client-go] DEBUG: 2023/12/17 12:29:27.793883 invoking command [generate]
[prisma-client-go] DEBUG: 2023/12/17 12:29:27.794620 running cli with args [generate]
[prisma-client-go] DEBUG: 2023/12/17 12:29:27.794625 global cache dir: /Users/ikennaalaneme/Library/Caches
[prisma-client-go] DEBUG: 2023/12/17 12:29:27.794658 ensuring CLI prisma-cli-darwin-arm64 from https://packaged-cli.prisma.sh/prisma-cli-5.7.0-darwin-arm64.gz to /Users/ikennaalaneme/Library/Caches/prisma/binaries/cli/5.7.0/prisma-cli-darwin-arm64
[prisma-client-go] DEBUG: 2023/12/17 12:29:27.794727 prisma cli is cached
[prisma-client-go] DEBUG: 2023/12/17 12:29:27.794730 checking query-engine darwin-arm64...
[prisma-client-go] DEBUG: 2023/12/17 12:29:27.794751 query-engine is cached at /Users/ikennaalaneme/Library/Caches/prisma/binaries/cli/5.7.0/79fb5193cf0a8fdbef536e4b4a159cad677ab1b9/prisma-query-engine-darwin-arm64
[prisma-client-go] DEBUG: 2023/12/17 12:29:27.794754 checking schema-engine darwin-arm64...
[prisma-client-go] DEBUG: 2023/12/17 12:29:27.794764 schema-engine is cached at /Users/ikennaalaneme/Library/Caches/prisma/binaries/cli/5.7.0/79fb5193cf0a8fdbef536e4b4a159cad677ab1b9/prisma-schema-engine-darwin-arm64
[prisma-client-go] DEBUG: 2023/12/17 12:29:27.794841 running /Users/ikennaalaneme/Library/Caches/prisma/binaries/cli/5.7.0/prisma-cli-darwin-arm64 [generate]

Running go run github.com/steebchen/prisma-client-go validate says my schema is valid.

Running go run github.com/steebchen/prisma-client-go debug shows that it is using by cache directory to process my queries.

@steebchen
Copy link
Owner

steebchen commented Dec 17, 2023

Thanks, first I saw the log agove might leak your credentials, so please change your credentials in your database immediately. I removed the log already so it doesn't happen in the future.

Can you please share your Prisma schema? You can also email it to contact@luca-steeb.com if you prefer 🙏

@RalphLincoln
Copy link
Author

Hi @steebchen I sent the schema lastweek to your mail. I had to rebuild the project again. But I noticed something. When connecting to my localhost, it's all good. But when connecting mongoDB atlas it is quite unstable.

[prisma-client-go] DEBUG: 2023/12/19 13:57:04.624319 version check took 6.791708ms
[prisma-client-go] DEBUG: 2023/12/19 13:57:04.624355 using query engine at /Users/ikennaalaneme/Library/Caches/prisma/binaries/cli/5.7.0/79fb5193cf0a8fdbef536e4b4a159cad677ab1b9/prisma-query-engine-darwin-arm64
[prisma-client-go] DEBUG: 2023/12/19 13:57:04.624358 ensure query engine took 7.046708ms
[prisma-client-go] DEBUG: 2023/12/19 13:57:04.626574 running query-engine on port 61270
[prisma-client-go] DEBUG: 2023/12/19 13:57:04.626757 datasources: [{"name":"db","url":"mongodb+srv://<username>:<password>@cluster0.rre55.mongodb.net/test-tentz?retryWrites=true\u0026w=majority"}]
[prisma-client-go] DEBUG: 2023/12/19 13:57:04.626763 starting engine...
[prisma-client-go] DEBUG: 2023/12/19 13:57:04.627862 connecting to engine...
[prisma-client-go] DEBUG: 2023/12/19 13:57:04.627909 prisma engine payload: `{}`
[prisma-client-go] DEBUG: 2023/12/19 13:57:04.629101 could not connect; retrying...
{"timestamp":"2023-12-19T12:57:04.634134Z","level":"INFO","fields":{"message":"Encountered error during initialization:"},"target":"query_engine"}
2023/12/19 13:57:04 expected value at line 1 column 1
exit status 1

@steebchen
Copy link
Owner

I see thanks. What do you mean with unstable, does it only occur sometimes? Or is it never working with atlas?

@RalphLincoln
Copy link
Author

As it is now, it's not working with my atlas db connection URL

@steebchen
Copy link
Owner

I can reproduce now at least, so I'm investigating

@steebchen

This comment was marked as outdated.

@steebchen steebchen linked a pull request Dec 24, 2023 that will close this issue
@steebchen
Copy link
Owner

Ok somehow the query engine is panicking on some connection URIs, I have yet to figure out why... (prisma/prisma-engines#4613)

@steebchen
Copy link
Owner

To temporarily fix the issue you should be able to do

go get github.com/steebchen/prisma-client-go@91a4abc62d3cd8bf08ccc3de290a8f15d41b83fe

and re-generate, it's a small fix to make env vars work again, I still have to figure out the actual issue but hopefully you can continue for now 🙏

@RalphLincoln
Copy link
Author

RalphLincoln commented Dec 28, 2023

Thanks @steebchen . Also, note that I had to edit my MongoDB connection string
mongodb+srv://<username>:<password>@cluster0.rre55.mongodb.net/?retryWrites=true&w=majority
to
mongodb+srv://<username>:<password>@cluster0.rre55.mongodb.net/

This worked fine.

@steebchen
Copy link
Owner

steebchen commented Dec 30, 2023

@RalphLincoln can you please try again with go get github.com/steebchen/prisma-client-go@a10327f06445dd9aa8edd63759ef253caf491541?

It should work with the full connection string. Please set it using an env var and not with .WithDatasourceURL, I would appreciate a lot if you could let me know if this works for you.

@RalphLincoln
Copy link
Author

@steebchen This worked fine.

@steebchen
Copy link
Owner

steebchen commented Jan 6, 2024

Thanks for letting me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants