Skip to content

FunctionsError loses message when serialized with JSON.stringify() #2225

Closed

Description

@oniani1

When you JSON.stringify() a FunctionsError (or any of its subclasses), the message property gets silently dropped from the output.

const err = new FunctionsHttpError('Edge Function returned a non-2xx status code', 'FunctionsHttpError', { status: 500 })
console.log(JSON.stringify(err))
// {"name":"FunctionsHttpError","context":{"status":500}}
// "message" is missing

This happens because Error.prototype.message is non-enumerable, so JSON.stringify() skips it.

The other error classes in this monorepo already handle this with a toJSON() override:

FunctionsError and its subclasses (FunctionsFetchError, FunctionsRelayError, FunctionsHttpError) are the only ones missing it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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