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.

bug: Seems tRPC (or its config) doesn't work when internet is off on local machine?

See original GitHub issue

Provide environment information

npx envinfo --system --binaries

  System:
    OS: macOS 13.0.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 589.69 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm

ct3a from package.json

  "ct3aMetadata": {
    "initVersion": "6.10.0"
  }

image

Describe the bug

tRPC hangs on the hello endpoint. I just get Loading tRPC query...

I don’t see an error but no success either.

To reproduce

Start up a freshly generated app (npm run dev) without the internet, open http://localhost:3000, I just get Loading tRPC query....

Additional information

Turning on the internet solves this. Does something require the internet? There are many times that I work offline and this prevents progress.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
needimcommented, Nov 19, 2022

seems related to: https://tanstack.com/query/v4/docs/guides/network-mode

Since React Query is most often used for data fetching in combination with data fetching libraries, the default network mode is online.

In this mode, Queries and Mutations will not fire unless you have network connection. This is the default mode. If a fetch is initiated for a query, it will always stay in the state (loading, error, success) it is in if the fetch cannot be made because there is no network connection. However, a fetchStatus is exposed additionally.

image

you can modify the behaviour via changing react-query’s networkMode configuration src/utils/trpc.ts

export const trpc = createTRPCNext<AppRouter>({
  config() {
    return {
      queryClientConfig: {
        defaultOptions: {
          queries: {
            networkMode:
              process.env.NODE_ENV === "development" ? "always" : "online",
          },
        },
      },
      transformer: superjson,
      links: [
        loggerLink({
          enabled: (opts) =>
            process.env.NODE_ENV === "development" ||
            (opts.direction === "down" && opts.result instanceof Error),
        }),
        httpBatchLink({
          url: `${getBaseUrl()}/api/trpc`,
        }),
      ],
    };
  },
  ssr: false,
});
0reactions
sdoxseecommented, Nov 19, 2022

Sounds good. Glad we can at least capture this issue so that other devs can see the solution. Thanks for all your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Still not fix 'no internet' connection bug in Windows 10 2004 ...
This issue occurs if you use a group policy or local network configuration to disable active probing for the Network Connectivity Status ...
Read more >
10 Troubleshooting Tips If Your Internet Is Connected But Not ...
Type ipconfig /flushdns and hit Enter. That's it, your DNS cache is now emptied and if that was the problem everything should work...
Read more >
How to fix Computer appears to be correctly configured but the ...
You can fix the internet connection problem "Computer appears to be correctly configured but the device or resource is not responding" in ...
Read more >
React 18: Hydration failed because the initial UI does not ...
I have been experiencing the same problem lately with NextJS and i am not sure if my observations are applicable to other libraries....
Read more >
Observing Tool (OT) - Gemini Observatory |
Before installing a new OT, make sure to sync all local changes with the ODBs. ... This machine needs internet access to communicate...
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