Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cleaning up Network Manager #50

Closed
jjordy opened this issue Apr 23, 2019 · 6 comments
Closed

Error: Cleaning up Network Manager #50

jjordy opened this issue Apr 23, 2019 · 6 comments
Labels
bug Something isn't working

Comments

@jjordy
Copy link

jjordy commented Apr 23, 2019

React version (e.g., 16.8.5)
16.8.5
Concurrent mode yes/no
Yes
Describe the bug
A clear and concise description of what the bug is.
More of a question than a bug
I am getting an error
Error: Cleaning up Network Manager

The app is a basic create react app with route level code splitting although the error seems to be thrown on my dashboard page which is not split into a separate bundle. I'm not sure this is related at all honestly its just something i was investigating.

Any ideas what could cause this error to be thrown?

Here is a basic example of my tree.

// index.tsx

ReactDOM.render(
  <RestProvider>
    <SharedState initialState={initialState}>
      <ThemeProvider theme={defaultTheme}>
        <React.Fragment>
          <GlobalStyles />
          <App />
        </React.Fragment>
      </ThemeProvider>
    </SharedState>
  </RestProvider>,
  document.getElementById("root")
)


// App.tsx

    <Location>
      {({ location }) => (
        <SuspenseLoader>
          <NetworkErrorBoundary
            key={location && location.key}
            fallbackComponent={({ error }) => (
              <CustomNetworkErrorBoundary error={error} />
            )}
          >
            <Router>
              <AuthenticatedApp path="/*" />
              <InitializeApplication path="/init/:token" />
              <NoAccess path="/no-access" />
              <NotFound default />
            </Router>
          </NetworkErrorBoundary>
        </SuspenseLoader>
      )}
    </Location>

// AuthenticatedApp.tsx

const Dashboard = lazy(() => import("./pages/Dashboard"))
const ISIR = lazy(() => import("./pages/ISIR"))
const Settings = lazy(() => import("./pages/Settings"))

interface AuthenticatedProps extends RouteComponentProps {}

const Authenticated: React.FC<AuthenticatedProps> = () => {
  useTokenData()

  return (
    <Suspense fallback={<LoadingPlaceholder />}>
      <Layout>
        <Router>
          <Dashboard path="/" exact />
          <ISIR path="/isir/*" />
          <Settings path="/settings/*" />
          <NotFound default />
        </Router>
      </Layout>
    </Suspense>
  )
}
@jjordy jjordy added the bug Something isn't working label Apr 23, 2019
@jjordy
Copy link
Author

jjordy commented Apr 23, 2019

Another note specifically what happens is when that when I browse the the problem page it works fine when i browse there but as soon as i make a code change or refresh the page it freezes during the suspense loading. and causes the tab to crash.

@jjordy
Copy link
Author

jjordy commented Apr 23, 2019

After further investigation I do believe this is related to Code splitting I just need to figure out exactly what is causing it. I will try to put together an example to see if this is related to the library or specifically my code.

Thanks,

Jordy

@ntucker
Copy link
Collaborator

ntucker commented Apr 23, 2019

https://github.com/coinbase/rest-hooks/blob/master/src/state/NetworkManager.ts#L33

That error is sent as a rejection to any open promises when cleanup() is called. This happens on unmount of <RestProvider />.

So I believe the problem is your <RestProvider/> is unmounting, which will not maintain state.

I would say your best bet is probably not having the <RestProvider/> part of the code hotreload. Alternatively you could look into using redux https://resthooks.io/docs/guides/redux#docsNav and making sure your store persists and only the reducers are hot reloaded.

@jjordy
Copy link
Author

jjordy commented Apr 23, 2019

Ok this makes sense do you think that would also cause the issue I'm seeing of it just freezing in the loading state and blowing up the tab either due to a memory leak / issue in my code or somewhere else?

@jjordy
Copy link
Author

jjordy commented Apr 23, 2019

I created a reproduction and was unable to reproduce. This is something inside my code as i was able to deeply nest lazy loaded routes in conjunction with useResource with no freezing issues.

Sorry for the trouble Thanks for the insight.

@jjordy jjordy closed this as completed Apr 23, 2019
@ntucker
Copy link
Collaborator

ntucker commented Apr 23, 2019

I would be interested to see if you could consistently reproduce this. It could be a bug in react, or an edge case in rest-hooks that could be ironed away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants