Closed tkxkd0159 closed 2 years ago
Hi @tkxkd0159 that is very strange. When morgan tries to write to the stream, it does not wait for the write to complete before continuing, and even then morgan does not write until after the response is completed. I tried with a basic app without issue.
Can you please provide an app that demonstrates the issue and include instructions for how to trigger the condition with the given app? We would be happy to debug the issue. Alternatively you're welcome to make a pull request that fixes the issue.
Thanks for your quick feedback @dougwilson !
My original repository where the problem occurred required several complicated setup processes, so I made a dummy repository that had similar problems (refresh issue). I made a simple example app that separates the backend and the front, and if you press the button called check morgan bug
, the bug is reproduced (Page is refreshed again for current location after receiving a response with fetch). You can also check this with chrome network tab
The address of the source is here. => https://github.com/tkxkd0159/debug-morgan
Hi @tkxkd0159 thanks for that! Are you sure the bug is due to morgan? I ask because in the reproduction code you provided, you have morgan commented out. If you are able to reproduce with that given app, it would seem the issue is unrelated to morgan.
Hi @dougwilson, sorry I forget to uncomment app.use(morgan("common", { stream: accessLogStream }));
so this code works fine (no bug). but when you uncomment morgan part, bus is reproduced.
Thanks. I guess I should clarify that I tried that, and your app acted the same if I had it commented out or not, so I wasn't sure if you were able to reproduce with that app. If that is the case, it seems that for some reason I am unable to reproduce on my system and unfortunately won't be able to help produce a fix without reproducing. You'll need to debug what the cause is and make a pull request with a fix 👍 , as it may be dependent on perhaps something on the system itself.
Thanks @dougwilson. For reference, my environment was Ubuntu 20.04.4 LTS. I'll try to debug this problem.
I tried to check issue this my mac (Monterey 12.4) and WIndows 10 machine. And there was no bug with morgan. Maybe there is something wrong with my linux machine or just compatible issue with Ubuntu focal. I will try to check this. Thanks
Ah, very interesting. And sorry for not including it, I was using Windows 11.
I tried to test with linux docker container and it works fine. Maybe there is something wrong with my local linux machine. There doesn't seem to be a problem with that package, and it seems to be a problem with my computer. Sorry for raising the wrong issue. I'll close this issue now that the issue has been resolved.
I encountered a problem when logging to a file instead of stdout in Morgan. In this setting, my google login refreshes the current page instead of going to the profile selection page.
I wrote the code as below.
Thank you.