-
Notifications
You must be signed in to change notification settings - Fork 210
event.data
undefined in onDocumentWritten
when migrating from V1 to V2 API
#1659
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
Comments
@taeold Daniel can you kindly look into this? The Typesense extension team is running into this while migrating to v2. |
@tharropoulos thanks for reporting! Can you share how you are testing the change? I mention that you didn't deploy this change, which make sense - there isn't a way to seemlessly upgrade your v1 functions to v2 function without downtime. See https://firebase.google.com/docs/functions/2nd-gen-upgrade |
@taeold Thanks for the quick reply! Let me clarify our testing setup and migration process: We're testing this using Firebase Emulators with Jest. Here's our testing flow:
"test-part-1": "firebase emulators:exec --only functions,firestore,extensions 'jest --testRegex=\"WithFlattening\" --testRegex=\"backfill.spec\"'"
const book = {
author: "Author A",
title: "Title X",
country: "USA",
};
const firestoreDoc = await firestore.collection(config.firestoreCollectionPath).add(book);
{
value: {
name: 'projects/ts-integration-aaf0c/databases/(default)/documents/books/xnx6fXYuOhKFJTCK2gq3',
fields: {
author: { stringValue: 'Author A' },
title: { stringValue: 'Title X' },
country: { stringValue: 'USA' }
},
createTime: '2025-01-22T07:33:05.633271Z',
updateTime: '2025-01-22T07:33:05.633271Z'
},
updateMask: {},
params: {},
data: undefined
} So when accessing the The key issue is we expected Is there a different way we should be accessing the document data in v2? Or do we need to adjust our emulator testing setup to properly support v2 functions? |
Closing this, we didn't format the resources correctly in our |
Related issues
#1464, but we measured the size of the responses and it does not exceed the 10MB threshold discussed in that issue.
[REQUIRED] Version info
node: v18.20.4
firebase-functions: 6.1.1
firebase-tools: 13.28.0
firebase-admin: 13.0.1
[REQUIRED] Test case
typesense/firestore-typesense-search#98
[REQUIRED] Steps to reproduce
When migrating from Firebase Functions v1 to v2 API, specifically from f
unctions.firestore.document().onWrite()
toonDocumentWritten()
, the event.data property is coming back as undefined.The existing V1 implementation of our
backfill
function:Migrating over to the
V2
API:Will result in functionality breaking, as
event.data
comes back as undefined.Here's the commit and diff in question.
[REQUIRED] Expected behavior
Returning the
data
object[REQUIRED] Actual behavior
event.data
is undefined.Were you able to successfully deploy your functions?
Did not deploy, caught in CI. The PR posted includes both a description of the changes and the test failure.
The text was updated successfully, but these errors were encountered: