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

Client breaks Next 'revalidate' #1861

Closed
adamghowiba opened this issue Mar 26, 2025 · 4 comments
Closed

Client breaks Next 'revalidate' #1861

adamghowiba opened this issue Mar 26, 2025 · 4 comments
Labels
bug 🔥 Something isn't working

Comments

@adamghowiba
Copy link

Description

When using @hey-api/client-fetch generated functions with Next.js, it seems to break the caching methods of Next.js.

Next.js wraps the default browser fetch and adds some addtional functionaility such as revalidate. Which allows requests to be cached, and revalidated.

For some reason when using standard fetch revalidate works, when using generated SDK functions they don't.

Reproducible example or configuration

page.tsx

import { listFilingTest } from '@ask-edgar/client/edgar-react-query';
import { API_BASE_URL } from '@ask-edgar/shared/constants';
import { TickerPage } from './TickerPage';

export default async function Ticker({
  params,
}: {
  params: Promise<{ ticker: string }>;
}) {
  const { ticker } = await params;

  // This call does respect the revalidate option despite everything being the same
  const response = await fetch(`${API_BASE_URL}/v1/sec/${ticker}/filing-test`, {
    next: {
      revalidate: 300,
    },
  });

  // This function doesn't seem to respect the `revalidate` option.
  const heyApiGeneratedSDK = await listFilingTest({
    path: {
      ticker: ticker,
    },
    next: {
      revalidate: 300,
    },
  });

  return <TickerPage ticker={ticker} />;
}

OpenAPI specification (optional)

No response

System information (optional)

No response

@adamghowiba adamghowiba added the bug 🔥 Something isn't working label Mar 26, 2025
@adamghowiba
Copy link
Author

adamghowiba commented Mar 26, 2025

After going through the @hey-api/client-fetch I realized that this isn't actually using native fetch but instead using new Request() to construct the request.

If possible, do you have any work-arounds to handling this?

Just want to say I love what you guys are doing, it's been a life saver. I'm a personal sponer of the project, and I'm trying to convince my company to sponer the porject but interoping with NextJS features is big for us so hoping there can be some middle-ground

@mrlubos
Copy link
Member

mrlubos commented Mar 26, 2025

@adamghowiba Thanks! How is this for the middle ground? https://heyapi.dev/openapi-ts/clients/next-js

@adamghowiba
Copy link
Author

@adamghowiba Thanks! How is this for the middle ground? https://heyapi.dev/openapi-ts/clients/next-js

You're truly a diamond in the rough when it comes to open source. Thanks for all the great work.

I'll keep bugging my company to sponser, thanks!

@mrlubos
Copy link
Member

mrlubos commented Mar 26, 2025

No worries! Let me know if you run into any issues with the Next.js client!

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