opral / inlang-message-sdk

0 stars 0 forks source link

Error in load-test due to generateMessageFile() partial JSON write #62

Closed jldec closed 1 month ago

jldec commented 1 month ago

Context

The error is caused by a large JSON file write which is picked up by the file watcher before completing.

$ pnpm test 4000 0 0
  load-test load-test start - using experimental persistence +0ms
  load-test opening repo and loading project +1ms
Using existing cloned repo
  load-test subscribing to project.errors +2s
  load-test generating 4000 messages +1ms
  load-test load-test done - exiting +34ms
  load-test load=test project errors SyntaxError: Unterminated string in JSON at position 1048576 +12ms

Proposal

Suggest to fix by writing the JSON file before calling loadProject().

Attempts to fix this using a temp file write + rename strategy solved the partial write issue, but this broke the node.js file watcher. see https://github.com/opral/monorepo/pull/2758