Ghost: Browser timeouts when importing
We pushed lot’s of importer improvements in the last year. I think the performance of the 1.x importer decreased a little, because we refactored the importer code base, fixed bugs and added more features.
One last improvement for the 1.x importer is missing. If you import a large JSON file via the browser, it can happen that a browser or nginx default timeout kicks in too early. Even thought that the server should still finish the import in the background, we should improve this, because the user doesn’t really understand what’s going on.
I think it’s impossible to extend (?) default timeouts for all supported/used browsers and even if we could, there is still a web-server component, which could timeout the connection.
So @kevinansfield and I think that adding short polling for the db import will resolve this. I think therefor we need to do:
- Upload the import file, return uploaded file path
- Trigger import with file path, immediate response and run in background
- Get result (simply e.g.
/db/import/result) - could simply returninProgress: true|falseand the import result with warnings and if it was imported or failed.
Triggering another import while one is active, should return an error. We can keep the import result in process, no need to persist it. If you restart Ghost while the import is running, the import won’t finish and nothing get’s changed in the database, because we run everything in a transaction. This is the easiest solution i can think of which should work.
NOTE: Currently, if you import a database, you are still able to send any GET/POST/… request to the Ghost API. This is not blocked/denied while the import is running. This is a different topic we might solve in the future. But actually unrelated to short polling.
@kevinansfield Leave any concerns/thoughts as comment 👍
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (9 by maintainers)
I have a ~700mb import from Wordpress. I increased timeouts in nginx and imported the file. The latest log I see is
Dec 01 11:30:08 localhost.localdomain node[812]: [2019-12-01 17:30:08] INFO "POST /ghost/api/v3/admin/db/" 200 67608msbut now ghost is unresponsive. Is there some database migration happening in the background I have to wait for? I gave up on waiting the first time and tried to restart ghost but it never stopped.
Would be really nice to tackle this soon. The browser timeout sucks 🙊
@sbrichards same issue, no need to open a separate one. Until an async background process and polling is implemented it’s typically safe to ignore the client timeout:
Hey folks - is this issue separate from the Node server closing the connection? I’m experiencing consistent import fails (file is 4MB), receiving 502 errors in the browser from the POST request after 2 minutes. I believe that’s due to Node’s default timeout is set at 2 minutes? https://nodejs.org/api/http.html#http_server_timeout
Is there a way to override that default setting? Should I open a separate issue for this or is it related?
Thanks!
If it’s a lot easier to do that then that’s fine, otherwise I think it makes more sense for a successful upload to automatically trigger the import