SQLite: Dates before 1970 panic. PANIC in /root/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/naive/datetime.rs:117:18invalid or out-of-range datetime
See original GitHub issueHi Prisma Team! My Prisma Client just crashed. This is the report:
Versions
| Name | Version |
|---|---|
| Node | v12.21.0 |
| OS | debian-openssl-1.1.x |
| Prisma Client | 2.17.0 |
| Query Engine | query-engine 3c463ebd78b1d21d8fdacdd27899e280cf686223 |
| Database | SQLite |
Query
mutation {
createOneClient(data: {
title: "X"
forename: "X"
surname: "X"
maidenName: "X"
gender: "X"
addressLine1: "X"
addressLine2: "X"
town: "X"
country: "X"
county: "X"
Postcode: "X"
email: "X"
mobile: "X"
telephone: "X"
altTelephone: "X"
dateOfBirth: "X"
}) {
id
createdAt
updatedAt
dateOfBirth
title
forename
middleName
maidenName
otherNames
surname
gender
addressLine1
addressLine2
town
country
county
Postcode
email
mobile
telephone
altTelephone
}
}
Logs
mcelreavey/Projects/crm/node_modules/@prisma/client/runtime/index.js:24857:25)
prisma:engine at Socket.emit (events.js:326:22)
prisma:engine at Socket.EventEmitter.emit (domain.js:483:12)
prisma:engine at endReadableNT (_stream_readable.js:1241:12)
prisma:engine at processTicksAndRejections (internal/process/task_queues.js:84:21) {
prisma:engine code: 'UND_ERR_SOCKET'
prisma:engine }
prisma:engine }
prisma:engine { cwd: '/home/jmcelreavey/Projects/crm/db' }
prisma:engine Search for Query Engine in /home/jmcelreavey/Projects/crm/node_modules/.prisma/client
plusX Execution permissions of /home/jmcelreavey/Projects/crm/node_modules/.prisma/client/query-engine-debian-openssl-1.1.x are fine
prisma:engine { flags: [ '--enable-raw-queries', '--port', '38477' ] }
prisma:engine stdout Starting a sqlite pool with 7 connections.
prisma:engine stdout Started http server on http://127.0.0.1:38477
prisma:engine Search for Query Engine in /home/jmcelreavey/Projects/crm/node_modules/.prisma/client
plusX Execution permissions of /home/jmcelreavey/Projects/crm/node_modules/.prisma/client/query-engine-debian-openssl-1.1.x are fine
prisma:engine stdout PANIC in /root/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/naive/datetime.rs:117:18
invalid or out-of-range datetime
prisma:engine TypeError: this.currentRequestPromise.cancel is not a function
prisma:engine at NodeEngine.handlePanic (/home/jmcelreavey/Projects/crm/node_modules/@prisma/client/runtime/index.js:26601:36)
prisma:engine at NodeEngine.setError (/home/jmcelreavey/Projects/crm/node_modules/@prisma/client/runtime/index.js:26547:16)
prisma:engine at LineStream.<anonymous> (/home/jmcelreavey/Projects/crm/node_modules/@prisma/client/runtime/index.js:26837:24)
prisma:engine at LineStream.emit (events.js:314:20)
prisma:engine at LineStream.EventEmitter.emit (domain.js:483:12)
prisma:engine at addChunk (_stream_readable.js:297:12)
prisma:engine at readableAddChunk (_stream_readable.js:272:9)
prisma:engine at LineStream.Readable.push (_stream_readable.js:213:10)
prisma:engine at LineStream.Transform.push (_stream_transform.js:152:32)
prisma:engine at LineStream._pushBuffer (/home/jmcelreavey/Projects/crm/node_modules/@prisma/client/runtime/index.js:23722:19) {"timestamp":"Feb 25 20:38:54.611","level":"ERROR","fields":{"message":"PANIC","reason":"invalid or out-of-range datetime","file":"/root/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/naive/datetime.rs","line":117,"column":18},"target":"query_engine","span":{"name":"Filter read query"},"spans":[{"name":"execute_single_operation"},{"name":"Filter read query"}]}
prisma:engine {
prisma:engine error: SocketError: other side closed
prisma:engine at Socket.onSocketEnd (/home/jmcelreavey/Projects/crm/node_modules/@prisma/client/runtime/index.js:24857:25)
prisma:engine at Socket.emit (events.js:326:22)
prisma:engine at Socket.EventEmitter.emit (domain.js:483:12)
prisma:engine at endReadableNT (_stream_readable.js:1241:12)
prisma:engine at processTicksAndRejections (internal/process/task_queues.js:84:21) {
prisma:engine code: 'UND_ERR_SOCKET'
prisma:engine }
prisma:engine }
prisma:engine Client Version: 2.17.0
prisma:engine Engine Version: query-engine 3c463ebd78b1d21d8fdacdd27899e280cf686223
prisma:engine Active provider: sqlite
prisma:engine {
prisma:engine error: Error: connect ECONNREFUSED 127.0.0.1:38477
prisma:engine at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) {
prisma:engine errno: 'ECONNREFUSED',
prisma:engine code: 'ECONNREFUSED',
prisma:engine syscall: 'connect',
prisma:engine address: '127.0.0.1',
prisma:engine port: 38477
prisma:engine }
prisma:engine }
Client Snippet
await db.client.create({
data: {
title: chance.prefix(),
forename: chance.first({ nationality: "en" }),
middleName: chance.bool() ? chance.first({ nationality: "en" }) : undefined,
surname: chance.last({ nationality: "en" }),
maidenName: chance.bool() ? chance.last({ nationality: "en" }) : undefined,
otherNames: chance.bool() ? chance.first({ nationality: "en" }) : undefined,
gender: chance.gender(),
addressLine1: chance.address({ addressLine1: true }),
addressLine2: chance.address({ addressLine2: true }),
town: city,
country: country,
county: chance.state({ city: city }),
Postcode: chance.postcode(),
email: chance.email(),
mobile: chance.phone({ mobile: true }),
telephone: chance.phone({ telephone: true }),
altTelephone: chance.bool() ? chance.phone() : undefined,
dateOfBirth: chance.birthday(),
},
}
Schema
model Client {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
dateOfBirth DateTime
title String
forename String
middleName String?
maidenName String?
otherNames String?
surname String
gender String
addressLine1 String
addressLine2 String
town String
country String
county String
Postcode String
email String
mobile String
telephone String
altTelephone String?
}
I believe there’s an issue when attempting to insert dates older than 1970 into SQLite
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Date And Time Functions - SQLite
SQLite supports six date and time functions as follows: ... of seconds since (or before) 1970-01-01 00:00:00 UTC (the unix timestamp).
Read more >SQLite Date & Time - How To Handle Date and Time in SQLite
This tutorial shows you how to work with the SQLite date and time values and use the built-in dates and times functions to...
Read more >how to choose SQLite date format - Stack Overflow
If you are concerned about total space and do not need any milliseconds or dates prior to 1970, then go for INTEGERs.
Read more >Get the Date/Time from a Unix Timestamp in SQLite
If you have a Unix timestamp, you can use SQLite's DATETIME() function with the unixepoch modifier to compute the actual date and time....
Read more >SQLite date and time functions | Atlassian Analytics
It converts the datetime value to seconds since 1970-01-01. %S. Seconds. It returns a number between and including 00-59 (60 seconds). %w. Day...
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

Ok, I just tried again with chance js and it is consistently reproducible now with some settings I tinkered. I should done that on the first run itself. Apologies for that.
Reproduction: https://github.com/harshit-test-org/prisma-issue-5854
FWIW I have seen this issue today as well. Prisma
2.18.0, using dates in1949and1950triggered the issue. Dates after1970worked successfully. Only seeing this with thesqliteprovider and notpostgres.