Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

404
Vistas
firebase Cloud Functions Error: RangeError: Maximum call stack size exceeded

I'm tring to get stock data from an api.

and I want it be updated at every 12:00 PM.

but when I tring to deploy this funtions, using

$firebase deploy --only functions

the error comes out.

Error: Failed to load function definition from source: Failed to generate manifest from function source: RangeError: Maximum call stack size exceeded

This is "index.ts" in funtions/src.

import * as functions from "firebase-functions";
import axios from "axios"
import { doc, getFirestore, setDoc, Timestamp } from 'firebase/firestore'
import { format } from 'date-fns'
import { initializeApp } from "firebase/app";

const firebaseConfig = {
    apiKey: "***********",
    authDomain: "****",
    projectId: "",
    storageBucket: "",
    messagingSenderId: "",
    appId: "",
    measurementId: ""
};

// Initialize Firebase
export const app = initializeApp(firebaseConfig);
export const db = getFirestore(app);

const API_KEY = "****************"

interface Wow {
    clpr: string
    srtnCd: string
}

const today = new Date();
const yesterday = today.setDate(today.getDate() - 1);
const basDt = format(yesterday, 'yyyyMMdd')

export const getStocks = functions
    .region('asia-northeast3')
    .pubsub.schedule('12 00 * * *')
    .timeZone('Asia/Seoul').onRun(async (context) => {
        await axios.get(`https://api.odcloud.kr/api/GetStockSecuritiesInfoService/v1/getStockPriceInfo?numOfRows=3000&resultType=json&basDt=${basDt}&serviceKey=${API_KEY}`)
            .then(response => {
                const wow: Wow[] = response.data.response.body.items.item
                wow.map((v, index) => {
                    setDoc(doc(db, 'KRX', v.srtnCd), { day: Timestamp.fromDate(today), price: v.clpr })
                })
                return null;
            })
    })

Another functions do work well . but if I include this one, It doesn't work.

What should I do?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Because this is your functions\src\index.ts file, you should only be exporting Cloud Functions from it and nothing else.

So change:

// Initialize Firebase
export const app = initializeApp(firebaseConfig);
export const db = getFirestore(app);

to:

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);

If you want to export an initialized Firebase SDK for use elsewhere, move it to its own file called functions\src\firebase.ts (or similar):

// firebase.ts
import { initializeApp } from "firebase-admin/app";
import { getFirestore } from "firebase-admin/firestore";

export const app = initializeApp(); // no arguments uses the default service account
export const db = getFirestore(app);

then use it like so:

import { app, db } from "./firebase.ts"

// NOTE: at time of writing, @google-cloud/firestore still uses the legacy namespaced syntax
db.doc("path/to/some/document") 
  .set({ /* data */ })
  .then(() => console.log('success'))
  .catch((err) => console.error('error', err));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda