Skip to content

Random runtime crashes in pkg on Windows #89

@mikiher

Description

@mikiher

What version of pkg are you using?

5.12.0

What version of Node.js are you using?

18.5.0

What operating system are you using?

Windows

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

node18-win-x64

Describe the Bug

This was reported by serveral audiobookshelf-windows users (I'm maintaining this app) in this bug.

In a nutshell, audiobookshelf-windows packs the Audiobookshelf server into a windows executable using yao-pkg and runs it from tray application. The pkg command and config can be found here. The server also uses a native addon (sqlite3) and pkg config puts the relevant .node files in the assets section.

Users have reported random crashes inside pkg runtime code, which I have not been able to reproduce, but I wanted to see if you've seen this before or have some advice.

The crashes seems to happen at random points, and all look roughly like this:

[2024-08-06 08:13:55.840] FATAL: [Server] Uncaught exception origin: uncaughtException, error: Error: ENOENT: no such file or directory, open 'C:\Users\shaun\AppData\Local\Temp\pkg-NGVozZ\88e6d330c6f684cce2af952a76696bfc3ba3d62a88e46fd9b599d7b54591a743'
    at Object.openSync (node:fs:599:3)
    at Object.openSync (pkg/prelude/bootstrap.js:793:32)
    at uncompressExternallyAndOpen (pkg/prelude/bootstrap.js:748:19)
    at pkg/prelude/bootstrap.js:763:32
    at FSReqCallback.oncomplete (node:fs:201:23) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'C:\\Users\\shaun\\AppData\\Local\\Temp\\pkg-NGVozZ\\88e6d330c6f684cce2af952a76696bfc3ba3d62a88e46fd9b599d7b54591a743'
} (    at process.<anonymous> (C:\snapshot\audiobookshelf\server\Server.js))
node:internal/fs/utils:347
    throw err;
    ^

Error: ENOENT: no such file or directory, open 'C:\Users\shaun\AppData\Local\Temp\pkg-NGVozZ\88e6d330c6f684cce2af952a76696bfc3ba3d62a88e46fd9b599d7b54591a743'
    at Object.openSync (node:fs:599:3)
    at Object.openSync (pkg/prelude/bootstrap.js:793:32)
    at uncompressExternallyAndOpen (pkg/prelude/bootstrap.js:748:19)
    at pkg/prelude/bootstrap.js:763:32
    at FSReqCallback.oncomplete (node:fs:201:23) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'C:\\Users\\shaun\\AppData\\Local\\Temp\\pkg-NGVozZ\\88e6d330c6f684cce2af952a76696bfc3ba3d62a88e46fd9b599d7b54591a743'
}

Expected Behavior

Obviously, not crash :)

To Reproduce

Unfortunately, I have not been able to repro this - I'm not quite sure how to trigger this as it seems to happen randomly and quite rarely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions