Title: `run` / `wait` can get stuck when using Next.js with App Router · Issue #136 · replicate/replicate-javascript · GitHub
Open Graph Title: `run` / `wait` can get stuck when using Next.js with App Router · Issue #136 · replicate/replicate-javascript
X Title: `run` / `wait` can get stuck when using Next.js with App Router · Issue #136 · replicate/replicate-javascript
Description: At yesterday's hackathon, a participant shared that predictions created and polled for completion using run would hang indefinitely, despite the Replicate dashboard showing that prediction as finishing minutes earlier. After debugging by...
Open Graph Description: At yesterday's hackathon, a participant shared that predictions created and polled for completion using run would hang indefinitely, despite the Replicate dashboard showing that prediction as finis...
X Description: At yesterday's hackathon, a participant shared that predictions created and polled for completion using run would hang indefinitely, despite the Replicate dashboard showing that prediction as f...
Opengraph URL: https://github.com/replicate/replicate-javascript/issues/136
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`run` / `wait` can get stuck when using Next.js with App Router ","articleBody":"At yesterday's hackathon, a participant shared that predictions created and polled for completion using `run` would hang indefinitely, despite the Replicate dashboard showing that prediction as finishing minutes earlier.\r\n\r\nAfter debugging by adding a `console.log` statement in the `progress` callback function, we determined that this behavior was caused by the extensions to `fetch` made by Next.js when using App Router [^1]. From [\"Data Fetching, Caching, and Revalidating\"](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating) in the Next.js docs:\r\n\r\n\u003e Next.js extends the native [fetch Web API](https://developer.mozilla.org/docs/Web/API/Fetch_API) to allow you to configure the [caching](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#caching-data) and [revalidating](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#revalidating-data) behavior for each fetch request on the server. React extends fetch to automatically [memoize](https://nextjs.org/docs/app/building-your-application/data-fetching/patterns#fetching-data-where-its-needed) fetch requests while rendering a React component tree.\r\n\u003e ...\r\n\u003e By default, **Next.js automatically caches the returned values of fetch in the [Data Cache](https://nextjs.org/docs/app/building-your-application/caching#data-cache)** on the server. This means that the data can be fetched at build time or request time, cached, and reused on each data request.\r\n\r\nBecause the initial `GET /v1/predictions/{id}` response was cached, subsequent requests polling for status returned the same response, which had the initial `\"starting\"` status.\r\n\r\nOur workaround involved setting `replicate.fetch` to a wrapped function that specified a [`cache: no-store` fetch option](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionscache). But it's unclear whether there's a better way to get the desired behavior.\r\n\r\nWe should either document or add a workaround to make this work correctly in Next.js.\r\n\r\n[^1]: `fetch` when using [Pages Router](https://nextjs.org/docs/pages/building-your-application), like in the [\"Build a website with Next.js\"](https://replicate.com/docs/get-started/nextjs) sample project, works as expected.","author":{"url":"https://github.com/mattt","@type":"Person","name":"mattt"},"datePublished":"2023-09-18T13:20:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/136/replicate-javascript/issues/136"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:89f6af4e-a0c4-af98-e880-f121a6360c21 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CBE6:2D3E84:275DA99:362EA03:6964E00B |
| html-safe-nonce | 11fe52f8226de3ed3618cf43abe10e79dbbbf5070506ff80b6accf3aab3d80ad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkU2OjJEM0U4NDoyNzVEQTk5OjM2MkVBMDM6Njk2NEUwMEIiLCJ2aXNpdG9yX2lkIjoiNjk1NDQ0MzE2NTIxNjg1ODEyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b7dc2a2978a1182ff546802c586f17b1d8690ee885a4b1ce1876be215d842195 |
| hovercard-subject-tag | issue:1900930405 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/replicate/replicate-javascript/136/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5b1fb24fc07fc99ae6c6912c486d357893c5a62148b6e69f75bd8483000fbf3f/replicate/replicate-javascript/issues/136 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5b1fb24fc07fc99ae6c6912c486d357893c5a62148b6e69f75bd8483000fbf3f/replicate/replicate-javascript/issues/136 |
| og:image:alt | At yesterday's hackathon, a participant shared that predictions created and polled for completion using run would hang indefinitely, despite the Replicate dashboard showing that prediction as finis... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mattt |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5838582163a1256e5ebd5086b7e1dc5cea93d82086c9c8b1395fb50f6ddab28d |
| turbo-cache-control | no-preview |
| go-import | github.com/replicate/replicate-javascript git https://github.com/replicate/replicate-javascript.git |
| octolytics-dimension-user_id | 60410876 |
| octolytics-dimension-user_login | replicate |
| octolytics-dimension-repository_id | 567870467 |
| octolytics-dimension-repository_nwo | replicate/replicate-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 567870467 |
| octolytics-dimension-repository_network_root_nwo | replicate/replicate-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8edad3509fd3b4374694551987974bbbcfd316c0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width