oramasearch / orama-plugin-strapi

3 stars 1 forks source link

Error after synchronization #4

Closed giogaspa closed 3 weeks ago

giogaspa commented 3 weeks ago

Hi, I have an error with the plugin when the synchronization ends and the orama-cloud_collections table is updated with new deployed_at date.

Here's the error:

postgres  | 2024-09-22 09:54:05.063 UTC [43] STATEMENT:  update "orama-cloud_collections" set "status" = $1, "deployed_at" = $2, "documents_count" = $3 where "id" = $4
node  | /app/node_modules/pg-protocol/dist/parser.js:283
node  |         const message = name === 'notice' ? new messages_1.NoticeMessage(length, messageValue) : new messages_1.DatabaseError(messageValue, length, name);
node  |                                                                                                  ^
node  | 
node  | error: update "orama-cloud_collections" set "status" = $1, "deployed_at" = $2, "documents_count" = $3 where "id" = $4 - date/time field value out of range: "1726998845062"
node  |     at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:283:98)
node  |     at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:122:29)
node  |     at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:35:38)
node  |     at Socket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:11:42)
node  |     at Socket.emit (node:events:519:28)
node  |     at Socket.emit (node:domain:488:12)
node  |     at addChunk (node:internal/streams/readable:559:12)
node  |     at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
node  |     at Readable.push (node:internal/streams/readable:390:5)
node  |     at TCP.onStreamRead (node:internal/stream_base_commons:191:23) {
node  |   length: 205,
node  |   severity: 'ERROR',
node  |   code: '22008',
node  |   detail: undefined,
node  |   hint: 'Perhaps you need a different "datestyle" setting.',
node  |   position: undefined,
node  |   internalPosition: undefined,
node  |   internalQuery: undefined,
node  |   where: "unnamed portal parameter $2 = '...'",
node  |   schema: undefined,
node  |   table: undefined,
node  |   column: undefined,
node  |   dataType: undefined,
node  |   constraint: undefined,
node  |   file: 'datetime.c',
node  |   line: '4028',
node  |   routine: 'DateTimeParseError'
node  | }

The error seems to be in the updatingCompleted function of the @oramacloud/plugin-strapi/server/services/orama-manager.js module. If I edit it with the code below, the update works fine.

  const updatingCompleted = async (collection, documents_count) => {
    return await collectionService.updateWithoutHooks(collection.id, {
      status: "updated",
      deployed_at: new Date(),   // <----- THIS
      ...(documents_count && { documents_count })
    })
  }

P.S. I'm using PostgreSQL as db.

Tell me if I can help you in any way. Thank you. Gioacchino