question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Story-specific handler / request persisting after switching stories

See original GitHub issue

Hi there! Thanks for the add-on!

I’m running into a problem with a story that demos a loading state:

  1. The Loading story applies a handler with ctx.delay('infinite'). This story works great!
    • Specifically, this is a graphql handler for a request from Apollo Client.
  2. But when I load that story and then switch to another story in the same file, that second story also appears as loading forever. The pending request from the first story remains in the network tab, and no new request appears from the second story.

Any help debugging / solving this would be appreciated! Please let me know if additional info would be helpful.

It’s a bit hard to debug this / pinpoint what part of the stack may be responsible for not ending the pending request and initiating a new one when switching from the Loading story to the next one. Apologies if I’m barking up the wrong tree.

In the meanwhile, since refreshing the browser tab on the second (non-loading) story allows that story to load correctly, I’ve worked around this by using a decorator that reloads the iframe when leaving the Loading story. This is the only workaround I’ve found that helps.

// Yuck...
Loading.decorators = [
  (Story) => {
    useEffect(() => {
      return () => window.location.reload();
    }, []);

    return <Story />;
  },
];

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:14
  • Comments:16

github_iconTop GitHub Comments

3reactions
tomgardiner-retailxcommented, Jul 7, 2022

I’m having this exact same issue - and it was related to when I started specifically passing in multiple mocks to the msw handler. I still don’t know what’s causing the issue, but thanks for your workaround.

Example of what caused it:

// Works
Primary.parameters = {
  msw: {
    handlers: [someMock],
  },
};
Secondary.parameters = {
  msw: {
    handlers: [someMock],
  },
}

//doesn't work
Primary.parameters = {
  msw: {
    handlers: [someMock, someMock2],
  },
};
Secondary.parameters = {
  msw: {
    handlers: [someMock, someMock2],
  },
}
2reactions
aaronmcadamcommented, Jul 29, 2022

I think if we had some way of resetting handlers like we can in unit tests (with server.resetHandlers()), that might help us make sure the story uses the correct handler.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Storybook and Mock Service Worker for mocked API ...
Mock Service Worker uses a worker script that enables requests ... For that, you can override request handlers on a per-story basis.
Read more >
README.md · branch/default · Games / harlowe - Projects
Toolbar: Fixed a bug where the status of the "Coding tooltips" setting wouldn't persist after closing and reopening the passage editor.
Read more >
How do you 'wiki' a string into a variable? (Sugarcube 2.21.0)
Hi. After some searching, I'm somewhat surprised that I haven't been able to find an elegant solution. What .
Read more >
@storybook/react-native-server | Yarn - Package Manager
... knob renders a switch which lets you toggle a value between true or false // you call ... Storyshots: Support story-specific options...
Read more >
An Authoring Framework for Interactive Narrative with Virtual ...
Discussion – The Problems of Application Design of Interactive Narrative . ... used to kill the king, when killing the king would change...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found