You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const express = require('express');
const cors = require('cors');
const app = express();
const port = 3001;
app.use(cors());
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
app.get('/', async (expressRequest, expressResponse) => {
console.log('start processing...');
// Detecting close event
expressRequest.on('close', function () {
const { destroyed } = expressRequest;
console.log('Client connection close....!', { destroyed });
});
await delay(5000);
if (!expressRequest.destroyed) {
console.log('sending response');
expressResponse.send('Hello World!')
}
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${ port }`)
})
[REQUIRED] Steps to reproduce
Run the Firebase function defined in the firebase-function.ts file locally in the emulator, via firebase emulators:start --only functions, and the native Express application, via node express-server.js.
Open the frontend.html file in your browser. When the firebase-function function is loaded by the emulator, click the send to function button in your browser and then (after about a second) the abort button.
Notice in the network tab of the browser's developer tools that the function call was canceled by the browser, but no information about it appeared in the emulator console.
Then click the send to express app button in your browser and, as before, after about a second, click abort. Similarly to the previous case, in the network dev tools tab of the browser you will see that the call has been canceled, but also in the console where the express application is running (express-server.js) you can see a log proving that the event informing about the request cancellation has been received by the application.
[REQUIRED] Expected behavior
The expected behavior is for the req.on('close') event to be triggered when the client (browser) cancels the HTTP request also for the requests received by Firebase Functions, just as it is for the native Express.js application.
[REQUIRED] Actual behavior
Currently, for calls received by the Firebase Function, the req.on('close') event fires only when the call completes, and nothing happens when the client cancels the call.
Were you able to successfully deploy your functions?
There are no problems with deploy
The text was updated successfully, but these errors were encountered:
@exaby73 yes, we observe the same behavior when the function is deployed. The req.on('close') event is fired only after the call is completed, i.e. after 5 seconds in the example provided.
Related issues
[REQUIRED] Version info
node:
v20.13.1
firebase-functions:
5.0.1
firebase-tools:
13.9.0
firebase-admin:
12.1.0
express
4.19.2
[REQUIRED] Test case
frontend.html
firebase-function.ts
express-server.js
[REQUIRED] Steps to reproduce
Run the Firebase function defined in the
firebase-function.ts
file locally in the emulator, viafirebase emulators:start --only functions
, and the native Express application, vianode express-server.js
.Open the
frontend.html
file in your browser. When thefirebase-function
function is loaded by the emulator, click thesend to function
button in your browser and then (after about a second) theabort
button.Notice in the network tab of the browser's developer tools that the function call was canceled by the browser, but no information about it appeared in the emulator console.
Then click the
send to express app
button in your browser and, as before, after about a second, clickabort
. Similarly to the previous case, in the network dev tools tab of the browser you will see that the call has been canceled, but also in the console where the express application is running (express-server.js
) you can see a log proving that the event informing about the request cancellation has been received by the application.[REQUIRED] Expected behavior
The expected behavior is for the
req.on('close')
event to be triggered when the client (browser) cancels the HTTP request also for the requests received by Firebase Functions, just as it is for the native Express.js application.[REQUIRED] Actual behavior
Currently, for calls received by the Firebase Function, the
req.on('close')
event fires only when the call completes, and nothing happens when the client cancels the call.Were you able to successfully deploy your functions?
There are no problems with deploy
The text was updated successfully, but these errors were encountered: