WIP Make kernel message handling async and in order #4697
…serving message order. Fixes jupyterlab#4188
… processing of old kernel messages in the async queue.
This also fixes at least one bug, where the shutdownAll was resolving before each shutdown actually resolved.
It's just good practice. I don't care if it is actually a promise, just that it is resolvable. For example, all the TS typings for resolve, etc., use PromiseLike.
…eleting one from the list.
This is so that code waiting on, for example, a status message will still resolve, especially in the case that the messages were buffered into another session. Any message handling that may require the current session (such as creating comms) should check to see if the message being handled is current.
It’s still a bit puzzling what is happening - it appears that the notebook is dropping messages from the kernel. More details at jupyter/notebook#3705.