Skip to content

onExit can return an undefined error #207

@ekilah

Description

@ekilah

The typings suggest that the error can be null | PlaidLinkError in the onExit callback. I've got bug reports from my production environment that suggest that error is occasionally/rarely undefined instead of null.

export type PlaidLinkOnExit = (
  error: null | PlaidLinkError,
  metadata: PlaidLinkOnExitMetadata
) => void;

Here's an example stack trace where we had a crash after we were filtering out error !== null explicitly:

TypeError Cannot read property 'error_type' of undefined 
    .../src/components/.../index.tsx:88:31 P.onExit
    .../src/components/.../index.tsx:145:15 Object.onExit
    https://cdn.plaid.com/link/v2/stable/link-initialize.js:1:66061 Object.exit
    https://cdn.plaid.com/link/v2/stable/link-initialize.js:1:47225 

Obviously a check for if (error) will work fine, so I expect many developers wouldn't even notice.

Assuming that this is actually an expected situation, it suggests there are deeper issues with the typings in the library. An obvious but probably incomplete fix is to change the types.ts file to also include undefined, so I wanted to make an issue first to see if anyone could figure out the rest.

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