firebase / firebase-functions

Firebase SDK for Cloud Functions
https://firebase.google.com/docs/functions/
MIT License
1.03k stars 202 forks source link

OnCall functions does not handle Date in return data #988

Open niklv opened 3 years ago

niklv commented 3 years ago

[REQUIRED] Version info

node: 14.17.2

firebase-functions: 3.15.7

firebase-tools: 9.20.0

firebase-admin: 9.12.0

[REQUIRED] Test case

const functions = require("firebase-functions")

module.exports.testFunc = functions.https.onCall((data, req) => ({
  d: new Date()
}))

[REQUIRED] Steps to reproduce

  1. Run emulator
  2. Make functions request

[REQUIRED] Expected behavior

Response must contain ISO formatted date. Like:

{
  "result": {
    "d": "2021-10-12T13:11:44.977Z"
  }
}

[REQUIRED] Actual behavior

Response must contain ISO formatted date. Like:

{
  "result": {
    "d": {}
  }
}
inlined commented 3 years ago

Dates are not part of the encoding specification for the onCall API. This is still a reasonable feature request. I'll label it as such.

christophe-g commented 1 month ago

Would be nice to have firestore.documentReference also as part of the encoding specification.

This would avoid issues like: https://github.com/firebase/firebase-functions/issues/1591

Document reference could be encoded as string, using their path