codelab-friendlychat-web
codelab-friendlychat-web copied to clipboard
The messages are not displayed
Describe the bug Build the demo Cloud Functions for Firebase. After completing the deploy, try to send the message, but no message displayed.
Errors in the console:
Uncaught TypeError: timestamp.toMillis is not a function
at createAndInsertMessage (main.js:265)
at displayMessage (main.js:299)
at main.js:77
at Array.forEach (<anonymous>)
at Object.next (main.js:72)
at next (database.ts:1825)
at async_observer.ts:51
Firebase-tools version: 7.7.0
To Reproduce Steps to reproduce the behavior:
- Deploy the project by following the sample Cloud Functions for Firebase
- Visit the page, input the message then send
Expected behavior The message is displayed on the page.
Additional context

Seems the toMillis function has been called twice https://github.com/firebase/friendlychat-web/blob/55d1ff58aff0131d3511bec9ccbfd4d8a99348b4/performance-monitoring-start/public/scripts/main.js#L77
https://github.com/firebase/friendlychat-web/blob/55d1ff58aff0131d3511bec9ccbfd4d8a99348b4/performance-monitoring-start/public/scripts/main.js#L277 which make the second time bumping error, also cause the message none show.
A quick fix is to make Line 277 as below
timestamp = timestamp ? timestamp : Date.now();
Show be check whether it has further side affect also direct modified on the sample codebase.