Skip to content
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

JSON string was partially returned when running function via Emulator #1474

Closed
nilinyi opened this issue Jul 5, 2019 · 4 comments · Fixed by #1488
Closed

JSON string was partially returned when running function via Emulator #1474

nilinyi opened this issue Jul 5, 2019 · 4 comments · Fixed by #1488

Comments

@nilinyi
Copy link

nilinyi commented Jul 5, 2019

Environment info

firebase-tools:
7.0.2

Platform:
macOS

Test case

Here is the code:

'use strict';

const FUNCTIONS = require('firebase-functions');
const ADMIN = require('firebase-admin');
ADMIN.initializeApp(FUNCTIONS.config().firebase); // Must be invoked before importing any other modules

exports.test = FUNCTIONS.https.onRequest((req, res) => {
    res.send({
        "events": [{
            "applicants": [],
            "latitude": 50.00525403677713,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "BSc0yXZILbaDWgHb0U3o",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 100.01933028798618,
            "geolocation": {
                "geohash_7": "y0zh7zp",
                "geohash_6": "y0zh7z",
                "geohash_5": "y0zh7",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 50.00525403677713,
                "geohash_9": "y0zh7zpve",
                "geohash_8": "y0zh7zpv",
                "longitude": 100.01933028798618
            }
        }, {
            "applicants": [],
            "latitude": 50.01345844676508,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "Hr1FzSbFHXCWQRw9Llbx",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 100.00143075971695,
            "geolocation": {
                "geohash_7": "y0zhe8d",
                "geohash_6": "y0zhe8",
                "geohash_5": "y0zhe",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 50.01345844676508,
                "geohash_9": "y0zhe8dvd",
                "geohash_8": "y0zhe8dv",
                "longitude": 100.00143075971695
            }
        }, {
            "applicants": [],
            "latitude": 50.01294618070128,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "KUwTov4vU6lfcNm6N38E",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 99.99410144063775,
            "geolocation": {
                "geohash_7": "y0zhe2t",
                "geohash_6": "y0zhe2",
                "geohash_5": "y0zhe",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 50.01294618070128,
                "geohash_9": "y0zhe2t6x",
                "geohash_8": "y0zhe2t6",
                "longitude": 99.99410144063775
            }
        }, {
            "applicants": [],
            "latitude": 50.00645698648151,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "VPBkHMBOYxrg7TyHYRNu",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 99.98157261550644,
            "geolocation": {
                "geohash_7": "y0zh7pk",
                "geohash_6": "y0zh7p",
                "geohash_5": "y0zh7",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 50.00645698648151,
                "geohash_9": "y0zh7pkke",
                "geohash_8": "y0zh7pkk",
                "longitude": 99.98157261550644
            }
        }, {
            "applicants": [],
            "latitude": 49.98709928565629,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "lp9RwqKLLVcEJsHKMUr1",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 100.00613333202384,
            "geolocation": {
                "geohash_7": "y0zh7ey",
                "geohash_6": "y0zh7e",
                "geohash_5": "y0zh7",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 49.98709928565629,
                "geohash_9": "y0zh7ey5z",
                "geohash_8": "y0zh7ey5",
                "longitude": 100.00613333202384
            }
        }, {
            "applicants": [],
            "latitude": 49.98778668034447,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "m0FWH7RAiGaGyUDAS6lk",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 99.9910899193208,
            "geolocation": {
                "geohash_7": "y0zh77g",
                "geohash_6": "y0zh77",
                "geohash_5": "y0zh7",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 49.98778668034447,
                "geohash_9": "y0zh77grc",
                "geohash_8": "y0zh77gr",
                "longitude": 99.9910899193208
            }
        }, {
            "applicants": [],
            "latitude": 49.98651826765737,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "oQxwxbjDd0F56xyIQRlV",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 100.0007266842588,
            "geolocation": {
                "geohash_7": "y0zh7ef",
                "geohash_6": "y0zh7e",
                "geohash_5": "y0zh7",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 49.98651826765737,
                "geohash_9": "y0zh7ef29",
                "geohash_8": "y0zh7ef2",
                "longitude": 100.0007266842588
            }
        }, {
            "applicants": [],
            "latitude": 49.989803363963425,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "pIjVwrGjdstxmRL2LtRX",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 99.98626132650382,
            "geolocation": {
                "geohash_7": "y0zh7hr",
                "geohash_6": "y0zh7h",
                "geohash_5": "y0zh7",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 49.989803363963425,
                "geohash_9": "y0zh7hrg8",
                "geohash_8": "y0zh7hrg",
                "longitude": 99.98626132650382
            }
        }, {
            "applicants": [],
            "latitude": 50.00834664175281,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "rMacoII9Brr3kSvuvm1j",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 100.01648835554931,
            "geolocation": {
                "geohash_7": "y0zh7zt",
                "geohash_6": "y0zh7z",
                "geohash_5": "y0zh7",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 50.00834664175281,
                "geohash_9": "y0zh7ztz9",
                "geohash_8": "y0zh7ztz",
                "longitude": 100.01648835554931
            }
        }, {
            "applicants": [],
            "latitude": 50.00834664175281,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "rMacoII9Brr3kSvuvm1j",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 100.01648835554931,
            "geolocation": {
                "geohash_7": "y0zh7zt",
                "geohash_6": "y0zh7z",
                "geohash_5": "y0zh7",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 50.00834664175281,
                "geohash_9": "y0zh7ztz9",
                "geohash_8": "y0zh7ztz",
                "longitude": 100.01648835554931
            }
        }, {
            "applicants": [],
            "latitude": 50.00834664175281,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "rMacoII9Brr3kSvuvm1j",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 100.01648835554931,
            "geolocation": {
                "geohash_7": "y0zh7zt",
                "geohash_6": "y0zh7z",
                "geohash_5": "y0zh7",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 50.00834664175281,
                "geohash_9": "y0zh7ztz9",
                "geohash_8": "y0zh7ztz",
                "longitude": 100.01648835554931
            }
        }, {
            "applicants": [],
            "latitude": 50.00834664175281,
            "description": "This is a test event.",
            "expire_time": "2019-07-06T22:19:37Z",
            "placemark": {
                "zip": "95014",
                "country": "US",
                "city": "Cupertino",
                "google_places_id": "google-inc",
                "name": "GOOGL",
                "street1": "10600 N Tantau Ave",
                "street2": "suit 101",
                "state": "CA"
            },
            "title": "TestEvent - 07/05/2019 15:19:37",
            "host_id": "geotest_user_id",
            "number_of_people": 2,
            "event_type": "INFORMAL",
            "guests": [],
            "id": "rMacoII9Brr3kSvuvm1j",
            "event_time": "2019-07-05T22:19:37Z",
            "is_cancelled": false,
            "longitude": 100.01648835554931,
            "geolocation": {
                "geohash_7": "y0zh7zt",
                "geohash_6": "y0zh7z",
                "geohash_5": "y0zh7",
                "geohash_4": "y0zh",
                "geohash_3": "y0z",
                "geohash_2": "y0",
                "geohash_1": "y",
                "latitude": 50.00834664175281,
                "geohash_9": "y0zh7ztz9",
                "geohash_8": "y0zh7ztz",
                "longitude": 100.01648835554931
            }
        }]
    });
});

Steps to reproduce

Run a firebase emulator using the code above and send a http GET request to path /test.

Expected behavior

The returned json is partial. Here is the returned json based on the above code:

{"events":[{"applicants":[],"latitude":50.00525403677713,"description":"This is a test event.","expire_time":"2019-07-06T22:19:37Z","placemark":{"zip":"95014","country":"US","city":"Cupertino","google_places_id":"google-inc","name":"GOOGL","street1":"10600 N Tantau Ave","street2":"suit 101","state":"CA"},"title":"TestEvent - 07/05/2019 15:19:37","host_id":"geotest_user_id","number_of_people":2,"event_type":"INFORMAL","guests":[],"id":"BSc0yXZILbaDWgHb0U3o","event_time":"2019-07-05T22:19:37Z","is_cancelled":false,"longitude":100.01933028798618,"geolocation":{"geohash_7":"y0zh7zp","geohash_6":"y0zh7z","geohash_5":"y0zh7","geohash_4":"y0zh","geohash_3":"y0z","geohash_2":"y0","geohash_1":"y","latitude":50.00525403677713,"geohash_9":"y0zh7zpve","geohash_8":"y0zh7zpv","longitude":100.01933028798618}},{"applicants":[],"latitude":50.01345844676508,"description":"This is a test event.","expire_time":"2019-07-06T22:19:37Z","placemark":{"zip":"95014","country":"US","city":"Cupertino","google_places_id":"google-inc","name":"GOOGL","street1":"10600 N Tantau Ave","street2":"suit 101","state":"CA"},"title":"TestEvent - 07/05/2019 15:19:37","host_id":"geotest_user_id","number_of_people":2,"event_type":"INFORMAL","guests":[],"id":"Hr1FzSbFHXCWQRw9Llbx","event_time":"2019-07-05T22:19:37Z","is_cancelled":false,"longitude":100.00143075971695,"geolocation":{"geohash_7":"y0zhe8d","geohash_6":"y0zhe8","geohash_5":"y0zhe","geohash_4":"y0zh","geohash_3":"y0z","geohash_2":"y0","geohash_1":"y","latitude":50.01345844676508,"geohash_9":"y0zhe8dvd","geohash_8":"y0zhe8dv","longitude":100.00143075971695}},{"applicants":[],"latitude":50.01294618070128,"description":"This is a test event.","expire_time":"2019-07-06T22:19:37Z","placemark":{"zip":"95014","country":"US","city":"Cupertino","google_places_id":"google-inc","name":"GOOGL","street1":"10600 N Tantau Ave","street2":"suit 101","state":"CA"},"title":"TestEvent - 07/05/2019 15:19:37","host_id":"geotest_user_id","number_of_people":2,"event_type":"INFORMAL","guests":[],"id":"KUwTov4vU6lfcNm6N38E","event_time":"2019-07-05T22:19:37Z","is_cancelled":false,"longitude":99.99410144063775,"geolocation":{"geohash_7":"y0zhe2t","geohash_6":"y0zhe2","geohash_5":"y0zhe","geohash_4":"y0zh","geohash_3":"y0z","geohash_2":"y0","geohash_1":"y","latitude":50.01294618070128,"geohash_9":"y0zhe2t6x","geohash_8":"y0zhe2t6","longitude":99.99410144063775}},{"applicants":[],"latitude":50.00645698648151,"description":"This is a test event.","expire_time":"2019-07-06T22:19:37Z","placemark":{"zip":"95014","country":"US","city":"Cupertino","google_places_id":"google-inc","name":"GOOGL","street1":"10600 N Tantau Ave","street2":"suit 101","state":"CA"},"title":"TestEvent - 07/05/2019 15:19:37","host_id":"geotest_user_id","number_of_people":2,"event_type":"INFORMAL","guests":[],"id":"VPBkHMBOYxrg7TyHYRNu","event_time":"2019-07-05T22:19:37Z","is_cancelled":false,"longitude":99.98157261550644,"geolocation":{"geohash_7":"y0zh7pk","geohash_6":"y0zh7p","geohash_5":"y0zh7","geohash_4":"y0zh","geohash_3":"y0z","geohash_2":"y0","geohash_1":"y","latitude":50.00645698648151,"geohash_9":"y0zh7pkke","geohash_8":"y0zh7pkk","longitude":99.98157261550644}},{"applicants":[],"latitude":49.98709928565629,"description":"This is a test event.","expire_time":"2019-07-06T22:19:37Z","placemark":{"zip":"95014","country":"US","city":"Cupertino","google_places_id":"google-inc","name":"GOOGL","street1":"10600 N Tantau Ave","street2":"suit 101","state":"CA"},"title":"TestEvent - 07/05/2019 15:19:37","host_id":"geotest_user_id","number_of_people":2,"event_type":"INFORMAL","guests":[],"id":"lp9RwqKLLVcEJsHKMUr1","event_time":"2019-07-05T22:19:37Z","is_cancelled":false,"longitude":100.00613333202384,"geolocation":{"geohash_7":"y0zh7ey","geohash_6":"y0zh7e","geohash_5":"y0zh7","geohash_4":"y0zh","geohash_3":"y0z","geohash_2":"y0","geohash_1":"y","latitude":49.98709928565629,"geohash_9":"y0zh7ey5z","geohash_8":"y0zh7ey5","longitude":100.00613333202384}},{"applicants":[],"latitude":49.98778668034447,"description":"This is a test event.","expire_time":"2019-07-06T22:19:37Z","placemark":{"zip":"95014","country":"US","city":"Cupertino","google_places_id":"google-inc","name":"GOOGL","street1":"10600 N Tantau Ave","street2":"suit 101","state":"CA"},"title":"TestEvent - 07/05/2019 15:19:37","host_id":"geotest_user_id","number_of_people":2,"event_type":"INFORMAL","guests":[],"id":"m0FWH7RAiGaGyUDAS6lk","event_time":"2019-07-05T22:19:37Z","is_cancelled":false,"longitude":99.9910899193208,"geolocation":{"geohash_7":"y0zh77g","geohash_6":"y0zh77","geohash_5":"y0zh7","geohash_4":"y0zh","geohash_3":"y0z","geohash_2":"y0","geohash_1":"y","latitude":49.98778668034447,"geohash_9":"y0zh77grc","geohash_8":"y0zh77gr","longitude":99.9910899193208}},{"applicants":[],"latitude":49.98651826765737,"description":"This is a test event.","expire_time":"2019-07-06T22:19:37Z","placemark":{"zip":"95014","country":"US","city":"Cupertino","google_places_id":"google-inc","name":"GOOGL","street1":"10600 N Tantau Ave","street2":"suit 101","state":"CA"},"title":"TestEvent - 07/05/2019 15:19:37","host_id":"geotest_user_id","number_of_people":2,"event_type":"INFORMAL","guests":[],"id":"oQxwxbjDd0F56xyIQRlV","event_time":"2019-07-05T22:19:37Z","is_cancelled":false,"longitude":100.0007266842588,"geolocation":{"geohash_7":"y0zh7ef","geohash_6":"y0zh7e","geohash_5":"y0zh7","geohash_4":"y0zh","geohash_3":"y0z","geohash_2":"y0","geohash_1":"y","latitude":49.98651826765737,"geohash_9":"y0zh7ef29","geohash_8":"y0zh7ef2","longitude":100.0007266842588}},{"applicants":[],"latitude":49.989803363963425,"description":"This is a test event.","expire_time":"2019-07-06T22:19:37Z","placemark":{"zip":"95014","country":"US","city":"Cupertino","google_places_id":"google-inc","name":"GOOGL","street1":"10600 N Tantau Ave","street2":"suit 101","state":"CA"},"title":"TestEvent - 07/05/2019 15:19:37","host_id":"geotest_user_id","number_of_people":2,"event_type":"INFORMAL","guests":[],"id":"pIjVwrGjdstxmRL2LtRX","event_time":"2019-07-05T22:19:37Z","is_cancelled":false,"longitude":99.98626132650382,"geolocation":{"geohash_7":"y0zh7hr","geohash_6":"y0zh7h","geohash_5":"y0zh7","geohash_4":"y0zh","geohash_3":"y0z","geohash_2":"y0","geohash_1":"y","latitude":49.989803363963425,"geohash_9":"y0zh7hrg8","geohash_8":"y0zh7hrg","longitude":99.98626132650382}},{"applicants":[],"latitude":50.00834664175281,"description":"This is a test event.","expire_time":"2019-07-06T22:19:37Z","placemark":{"zip":"95014","country":"US","city":"Cupertino","google_places_id":"google-inc","name":"GOOGL","street1":"10600 N Tantau Ave","street2":"suit 101","state":"CA"},"title":"TestEvent - 07/05/2019 15:19:37","host_id":"geotest_user_id","number_of_people":2,"event_type":"INFORMAL","guests":[],"id":"rMacoII9Brr3kSvuvm1j","event_time":"2019-07-05T22:19:37Z","is_cancelled":false,"longitude":100.01648835554931,"geolocation":{"geohash_7":"y0zh7zt","geohash_6":"y0zh7z","geohash_5":"y0zh7","geohash_4":"y0zh","geohash_3":"y0z","geohash_2":"y0","geohash_1":"y","latitude":50.00834664175281,"geohash_9":"y0zh7ztz9","geohash_8":"y0zh7ztz","longitude":100.01648835554931}},{"applicants":[],"latitude":50.00834664175281,"description":"This is a test event.","expire_time":"2019-07-06T22:19:37Z","placemark":{"zip":"95014","country":"US","city":"Cupertino","google_places_id":"google-inc","name":"GOOGL","street1":"10600 N Tantau Ave","street2":"suit 101","state":"CA"},"title":"TestEvent - 07/05/2019 15:19:37","host_id":"geotest_user_id","number_of_people":2,"event_type":"INFORMAL","guests":[],"id":"rMacoII9Brr3kSvuvm1j","event_time":"2019-07-05T22:19:37Z","is_cancelled":false,"longitude":100.01648835554931,"geolocation":{"geohash_7":"y0zh7zt","geohash_6":"y0zh7z","geohash_5":"y0zh7","geohash_4":"y0zh","geohash_3":"y0z","geohash_2":"y0","geohash_1":"y","latitude":50.00834664175281,"geohash_9":"y0zh7ztz9","geohash_8":"y0zh7ztz","longitude":100.01648835554931}},{"applicants":[],"latitud

Actual behavior

It should return the complete json.

@nilinyi nilinyi changed the title Only partial json file returned when using Emulator JSON string was partially returned when running function via Emulator Jul 5, 2019
@keeganbrown
Copy link

Also having this issue. It seems that JSON payloads beyond a certain size are partially returned. The response also includes ERR_CONTENT_LENGTH_MISMATCH network error in chrome. Downgrading to firebase-tools@6 (and associated firebase-admin and firebase-functions) fixes the issue.

@samtstern
Copy link
Contributor

@nilinyi thanks for the detailed bug report! Hopefully the fix will be simple (and @keeganbrown the point about ERR_CONTENT_LENGTH_MISMATCH is very useful)

@samtstern
Copy link
Contributor

samtstern commented Jul 8, 2019

Ok I have a simple reproduction:

exports.helloWorld = functions.https.onRequest((request, response) => {
    const numItems = request.param('num');
    const obj = {};

    let i = 0;
    while (i < numItems) {
        obj[uuidv1()] = uuidv1();
        i++;
    }

    response.header('x-num-items', "" + i);
    response.send(obj);
});

If I use small parameters for num it works but larger parameters (like http://localhost:5001/fir-dumpster/us-central1/helloWorld?num=100000) fail


I found the line (in this specific example). 2808 works but 2909 does not:

$ http -h http://localhost:5001/fir-dumpster/us-central1/helloWorld?num=2808
HTTP/1.1 200 OK
connection: keep-alive
content-length: 219025
content-type: application/json; charset=utf-8
date: Mon, 08 Jul 2019 16:56:37 GMT
etag: W/"35791-4tTqTZQ8UAjccNQTk2zJalwHm2Y"
x-num-items: 2808
x-powered-by: Express
$ http -h http://localhost:5001/fir-dumpster/us-central1/helloWorld?num=2809
HTTP/1.1 200 OK
connection: keep-alive
content-length: 219103
content-type: application/json; charset=utf-8
date: Mon, 08 Jul 2019 16:56:41 GMT
etag: W/"357df-T2rFVD93kOmxiT0WssRX3rBfx90"
x-num-items: 2809
x-powered-by: Express

So the "too big" line is somewhere between 219025 and 219103

@samtstern
Copy link
Contributor

@abeisgoat the only clue I have here is that in functionsEmulator we normally only get an end event but when the problem above happens we get end and then close which implies that the temporary file we're using as a socket could be closing too early.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants