You are correct that you asked the question first but I do not see anything inherently wrong with what happened for the following reasons:
The GitHub issue you opened was created after the second questionsecond question was asked. It appears as if the duplicate question was generated independently of yours (no intent to steal your question).
When there is a duplicate, preserving answers is sometimes more important than preserving the question that was asked first. Since your question was never answered (before being closed as a duplicate) and the second question did have an answer there is a reasonable basis for which question was closed.
If your objection is primarily about "fairness" or SE reputation I would suggest you do the following:
Provide a better answer to the question that remains open when it becomes available since you have stated you believe there is not yet a confirmed solution to your problem.
In the future, feel free to answer your own question even prior to the solution being 100% complete. You can always return to edit your answer later to make it more complete.