Skip to content

UnhandledPromiseRejectionWarning: Error: BUFFER_SHORTAGE #2337

Open
@thelindat

Description

@thelindat

What happened?

Calling an async export when a script is stopping leads to the following error.

(node:8880) UnhandledPromiseRejectionWarning: Error: BUFFER_SHORTAGE
    at n.e [as reserve] (citizen:/scripting/v8/msgpack.js:29:12766)
    at h (citizen:/scripting/v8/msgpack.js:29:15761)
    at n.r [as decode] (citizen:/scripting/v8/msgpack.js:29:13908)
    at n.fetch (citizen:/scripting/v8/msgpack.js:29:6972)
    at n.u [as read] (citizen:/scripting/v8/msgpack.js:29:12076)
    at Object.n [as decode] (citizen:/scripting/v8/msgpack.js:29:7097)
    at unpack (citizen:/scripting/v8/main.js:50:33)
    at citizen:/scripting/v8/main.js:82:21
    at Number.__cfx_wrap_38 (citizen:/scripting/v8/main.js:23:12)
    at citizen:/scripting/v8/main.js:29:16
(Use `FXServer --trace-warnings ...` to show where the warning was created)
ba(node:8880) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)

Expected result

Either discard the error or give a more sensible message.

Reproduction steps

  1. Create an async export in a resource using the v8 scrt (resource A).
  2. Add an event handler in another resource (resource B), listening for onResourceStop.
  3. Call the export from resource B.
  4. When resource A tries to return to the invoking resource, msgpack throws the error above.

Importancy

Slight inconvenience

Area(s)

ScRT: JS

Specific version(s)

Server 7290

Additional information

Using a try-catch block here will catch the error, but I'm unsure if it's indicative of issue elsewhere.

https://github.com/citizenfx/fivem/blob/master/data/shared/citizen/scripting/v8/main.js#L29

Metadata

Metadata

Assignees

No one assigned

    Labels

    ScRT: JSIssues/PRs related to the JavaScript scripting runtimebugtriageNeeds a preliminary assessment to determine the urgency and required action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions