firebase / firebase/firebase-tools

NextJS - Extreme latency and out of memory cloud functions on Firebase after upgrading next to >13.4.12

Open
#6,349 4 comments 6 reactions 0 assignees View on GitHub
integration: web frameworks type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:** 12.5.2

**Platform:** MacOS 13.2.1 , MBP Pro M2 Pro,

### [REQUIRED] Test case

https://github.com/heliohm/next-firebase-debug-latency

### [REQUIRED] Steps to reproduce

- Enable web frameworks experiment for firebase, create new firebase project
- Deploy repository to the Firebase project
- Deployed example available temporarily at \.web.app at endpoints /api/ping, /api/ping-auth (loading FB Auth) and /api/hello (default NextJS route from create-next-app)

### [REQUIRED] Expected behavior

NextJS SSR cloud function latency is typically 1-200ms after cold start

### [REQUIRED] Actual behavior

- API responses from NextJS cloud run function will always take several seconds, also with minInstances > 0.
- The minimum example latency is 1-3 seconds, the real application takes 5-10 seconds for every API call.
- Frequent out of memory messages (not always) in SSR cloud function logs in google cloud logs unless memory is set to 1GiB for the real project (for which the SSR part is very small)
- Downgrading to next.js 13.4.12 makes the problem go away.
- Behaviour in firebase emulator (real project emulates hosting+auth+firestore) is good

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.