Skip to content

Serialized error when call in serverSide the getVariant() #110

@davi-monteiro

Description

@davi-monteiro

Describe the bug

When call get Variants in serverSide, the response return undefined payload in type IVariant.

Steps to reproduce the bug

  1. call getVariant() in server side
  2. in time of execution the nextJs, write a error in console.

Expected behavior

When attr payload not exists in response of getVariants, the default is null.

I create a serialization to run without errors.

const serializePayload = (variant: IVariant) => {
  return {
    ...variant,
    payload: variant.payload ?? null,
  };
};

Logs, error output, etc.

⨯ Error: Error serializing `.responseVariant.payload` returned from `getServerSideProps` in "/page/[[...params]]".
Reason: `undefined` cannot be serialized as JSON. Please use `null` or omit this value.
    at Array.every (<anonymous>)
    at Array.every (<anonymous>)
    at Array.every (<anonymous>)

Screenshots

Our implementation, with serialized solution:
Image

Error in terminal
Image

Additional context

No response

Unleash version

1.4.4 but in new version not found.

Subscription type

None

Hosting type

None

SDK information (language and version)

@unleash/nextjs/client:1.4.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions