linearlabs-workspace / storybook-addon-mock

This addon allows you to mock fetch or XMLHttpRequest in the storybook.
https://storybook-addon-mock.netlify.app
MIT License
112 stars 46 forks source link

Uncaught TypeError: Object(...) is not a function looped error @ faker.js matchMock #155

Open hardfi opened 1 year ago

hardfi commented 1 year ago

Mocking requests works fine, but there's an infinite loop causing excessive resources usage, which prevents us from releasing code to server.

Screenshot 2023-01-02 at 14 40 31

Storybook configuration:

    "@dreamworld/addon-redux": "^1.1.0",
    "@storybook/addon-actions": "^6.5.15",
    "@storybook/addon-essentials": "^6.5.15",
    "@storybook/addon-links": "^6.5.15",
    "@storybook/preset-scss": "^1.0.3",
    "@storybook/react": "^6.5.15",
    "@storybook/storybook-deployer": "^2.8.16",
    "storybook-addon-mock": "3.2.0"

Downgrading to versions 3.1.0 and 3.0.0 did not help - with these versions story preview does not show at all (error). Before adding storybook-addon-mock everything worked as expected.

The callback function in matchMock method in esm/utils/faker.js receives '/runtime-error' as a parameter (url) but there is no request like this made anywhere by the app so I assume this is some Storybook internals.

The bug is quite serious because even navigating away from the story using the storybook-addon-mock does not stop the overflow.

I'd be very happy to see a solution/work-around for this issue as it prevents us from using our most crucial stories.

Thanks!

hanna-seraya commented 1 year ago

happens for me as well with the latest version 4.0.0 and SB v.7

nutboltu commented 1 year ago

@hanna-seraya @hardfi do you have any sandbox to reproduce this issue?