I went with a way to return thread_data, mostly so I can deal with failure. If you think it's not important I can change it to your suggestion.
I don't think we need to worry about error handling too much here. If we get here, we probably already needed to process some task.
Not really related to this MR, but I'd even consider something like creating the thread data early in `create_document_object` and fail there if needed. With that in place, the data would be missing only if we somehow query for it from a wrong thread, which is not supported by MSHTML anyway and surely not the case for Gecko notifications.