Skip to content

isJSONSerializable bug #571

Description

@magion33

Environment

Any environment, any version. Present from the start it seems like.

Reproduction

Running isJSONSerializable(null) serves sufficiently as a reproduction of the bug.

Describe the bug

This line has a bug.

if (t === "string" || t === "number" || t === "boolean" || t === null) {

Firstly, t (typeof value) will never triple equal null. (dead code)
Secondly, null as a value is JSON serializable. This util function will not identify it as such.
Thirdly, if you provide null to this util function, it will throw:

Uncaught TypeError: Cannot read properties of null (reading 'buffer')
    at isJSONSerializable

Additional context

Can I create a PR fix?

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions