I just realized that there might be an implicit race condition in this:
When the query is completed:
The backend will unset the uuid from queryMap.
The backend will return the progress to frontend.
The frontend will unset the setInterval function to stop polling after receiving the query result.
However, if a polling occurs between 2 and 3, there is a chance that the frontend receives a data object of undefined due to that the uuid has already been erased in step 1, causing a failure in handling the result.
I propose that the backend returns status 404 instead of sending undefined to frontend when the uuid does not exist in the map. Then, for Axios.get(/api/cypher/result/${this.cellId}), an error handler can be added to handle the 404. In case of error, it can simply ignore without doing anything.
I just realized that there might be an implicit race condition in this: When the query is completed:
uuid
fromqueryMap
.setInterval
function to stop polling after receiving the query result.However, if a polling occurs between 2 and 3, there is a chance that the frontend receives a data object of
undefined
due to that theuuid
has already been erased in step 1, causing a failure in handling the result.I propose that the backend returns status
404
instead of sendingundefined
to frontend when theuuid
does not exist in the map. Then, forAxios.get(
/api/cypher/result/${this.cellId})
, an error handler can be added to handle the404
. In case of error, it can simply ignore without doing anything.