Initialization of global 'client' in progress.
# help
k
Why is this stopping my process? And how to avoid it?
f
Globals and statics are initialized at first access.
Once the initializer has been finished, the return value is assigned to the global and used from then one.
The error message you are getting is, because something accessed a global (
client
) in a task, but hasn't returned yet. In a different task you accessed the same global, which leads to the error.
Actually. I'm wrong; In that case we just wait for the first one to finish.
What you are hitting here is simpler: You are trying to read a global that is being initialized while initializing it.
Simplified example:
Copy code
use_global:
  print global
  return 499
global := use_global

main:
  print global
In your case the global is
client
.
It's not completely clear why
client
is showing up in the stack-trace, though. In my test-case, the
global
name is the last one before
run_global_initializer_
.
Do you maybe have a bit more context?
k
I found the error. Just some variable-name errors. Thanks for the help 😄
Although, I do have another question. I updated Visual Studio to the 2022 update, and now I am missing the Toit Extentions. But when I try to install it, nothing really happens. Visual Studio doesn't really react, and I can't find Toit anymore on their "marketplace". Have you seen this before?
f
Visual studio 2022 and vscode are two completely different products. I don't think their extensions are compatible.
k
You are correct, and I have made a big but innocent mistake. I am back on track now 😄 What vacations doesn't do to you 😄
Now I've fixed the client, but I get this stack trace error now
I fixed this, but I don't understand how. So, I start the client in the beginning of main, then everything works. But if I call a "client.start" in a function instead, it will give this stack-trace
f
The stacktrace seems to indicate that the client isn't connected yet.
The null-error is on
session_
which is set during
connect
.
Setting the
session_
is one of the first things
connect
does.
My guess is, it hasn't been called yet.
r
jag