Error while provisioning Astilectron
Closed this issue · 7 comments
Hi, I am getting this error while trying to run the astilelectron window which simply displays an HTML file. I am using go version 1.16 and astilectron version is go-astikit v0.21.1 and go-astilectron v0.24.0
2021/05/11 23:12:31 astikit: starting worker...
2021/05/11 23:12:31 Starting...
2021/05/11 23:12:31 Provisioning...
2021/05/11 23:12:31 Provisioning Astilectron...
2021/05/11 23:12:31 Removing directory C:\Users\me\AppData\Roaming\App\vendor\astilectron
2021/05/11 23:12:31 Downloading https://github.com/asticode/astilectron/archive/v0.48.0.zip into C:\Users\me\AppData\Roaming\App\vendor\astilectron-v0.48.0.zip
2021/05/11 23:12:31 astikit: sending GET request to https://github.com/asticode/astilectron/archive/v0.48.0.zip (1/1)
2021/05/11 23:12:52 Removing C:\Users\me\AppData\Roaming\App\vendor\astilectron-v0.48.0.zip...
2021/05/11 23:12:52 Closing...
2021/05/11 23:12:52 astikit: stopping worker...
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x61daf5]
goroutine 51 [running]:
github.com/asticode/go-astilectron.(*writer).write(0x0, 0x6e69eb, 0x11, 0x6f0731, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
C:/code/app/vendor/github.com/asticode/go-astilectron/writer.go:39 +0x255
github.com/asticode/go-astilectron.synchronousEvent.func1(0xc0001b6140, 0x6ecc69)
C:/code/app/vendor/github.com/asticode/go-astilectron/helper.go:145 +0xd8
github.com/asticode/go-astilectron.synchronousFunc(0x75ce78, 0xc0001b6180, 0x757740, 0xc0001be140, 0xc00025f4d0, 0x6ecc69, 0x1c, 0x251daf22a88, 0x20, 0x20, ...)
C:/code/app/vendor/github.com/asticode/go-astilectron/helper.go:133 +0x20c
github.com/asticode/go-astilectron.synchronousEvent(0x75ce78, 0xc0001b6180, 0x757740, 0xc0001be140, 0x0, 0x6e69eb, 0x11, 0x6f0731, 0x1, 0x0, ...)
C:/code/app/vendor/github.com/asticode/go-astilectron/helper.go:144 +0x145
github.com/asticode/go-astilectron.(*Window).Create(0xc0001be140, 0xc0001c0680, 0x3d)
C:/code/app/vendor/github.com/asticode/go-astilectron/window.go:310 +0x1d3
Please, can you help to solve this problem?
Can you show me the portion of your code that calls astilectron.New()
?
Hi Quentin,
Thanks for the reply!
I am calling DisplayWindow() as a go-routine
Code:
`
func DisplayWindow() {
l := log.New(log.Writer(), log.Prefix(), log.Flags())
baseDir, _ := filepath.Abs("path")
a, err := astilectron.New(nil, astilectron.Options{
AppName: "Sample",
BaseDirectoryPath: baseDir,
})
if err != nil {
Log().Error().Msgf("main: creating astilectron failed: %w", err)
}
defer a.Close()
a.HandleSignals()
// Error is getting generated here
if err = a.Start(); err != nil {
Log().Error().Msgf("starting astilectron failed: %w", err)
}
var w *astilectron.Window
if w, err = a.NewWindow("path_of_html_file", &astilectron.WindowOptions{
Center: astikit.BoolPtr(true),
Height: astikit.IntPtr(700),
Width: astikit.IntPtr(700),
}); err != nil {
Log().Error().Msgf("new window failed: %w", err)
}
if err = w.Create(); err != nil {
Log().Error().Msgf("creating window failed: %w", err)
}
// Blocking pattern
a.Wait()
}
`
I can't reproduce the error, but could you try setting l
instead of nil
in your call to astilectron.New()
?
Yes, this is the output of it
I have changed AppName to "Example"
logged error:
"starting astilectron failed: %!w(*fmt.wrapError=&{provisioning failed: provisioning astilectron failed: moving Astilectron failed: downloading https://github.com/asticode/astilectron/archive/v0.48.0.zip into C:\Users\me\AppData\Roaming\Example\vendor\astilectron-v0.48.0.zip failed: DownloadInFile failed: astikit: sending request to https://github.com/asticode/astilectron/archive/v0.48.0.zip failed: astikit: sending GET request to https://github.com/asticode/astilectron/archive/v0.48.0.zip (1/1) failed: Get "https://github.com/asticode/astilectron/archive/v0.48.0.zip\": dial tcp 13.234.176.102:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 0xc000042fe0})"
log displayed on console:
2021/05/12 14:54:18 astikit: starting worker...
2021/05/12 14:54:18 Starting...
2021/05/12 14:54:18 Provisioning...
2021/05/12 14:54:18 Provisioning Astilectron...
2021/05/12 14:54:18 Removing directory C:\Users\me\AppData\Roaming\Example\vendor\astilectron
2021/05/12 14:54:18 Downloading https://github.com/asticode/astilectron/archive/v0.47.0.zip into C:\Users\me\AppData\Roaming\Example\vendor\astilectron-v0.47.0.zip
2021/05/12 14:54:18 astikit: sending GET request to https://github.com/asticode/astilectron/archive/v0.47.0.zip (1/1)
2021/05/12 14:54:39 Removing C:\Users\me\AppData\Roaming\Example\vendor\astilectron-v0.47.0.zip...
2021/05/12 14:54:39 Closing...
2021/05/12 14:54:39 astikit: stopping worker...
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x89dd55]goroutine 37 [running]:
github.com/asticode/go-astilectron.(*writer).write(0x0, 0x967e31, 0x11, 0x971c96, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
C:/code/app/vendor/github.com/asticode/go-astilectron/writer.go:39 +0x255
github.com/asticode/go-astilectron.synchronousEvent.func1(0xc000264080, 0x96e14d)
C:/code/app/vendor/github.com/asticode/go-astilectron/helper.go:145 +0xd8
github.com/asticode/go-astilectron.synchronousFunc(0x9defd8, 0xc0002640c0, 0x9d98a0, 0xc000242050, 0xc0000654d0, 0x96e14d, 0x1c, 0x22156228548, 0x20, 0x20, ...)
C:/code/app/vendor/github.com/asticode/go-astilectron/helper.go:133 +0x20c
github.com/asticode/go-astilectron.synchronousEvent(0x9defd8, 0xc0002640c0, 0x9d98a0, 0xc000242050, 0x0, 0x967e31, 0x11, 0x971c96, 0x1, 0x0, ...)
C:/code/app/vendor/github.com/asticode/go-astilectron/helper.go:144 +0x145
github.com/asticode/go-astilectron.(*Window).Create(0xc000242050, 0xc000204300, 0x3d)
C:/code/app/vendor/github.com/asticode/go-astilectron/window.go:309 +0x1d3
OK got it. Basically there's a problem in your code: you don't return when err != nil
. You should do
if err = a.Start(); err != nil {
Log().Error().Msgf("starting astilectron failed: %w", err)
return
}
instead of
if err = a.Start(); err != nil {
Log().Error().Msgf("starting astilectron failed: %w", err)
}
In your case, a.Start()
fails, therefore astilectron
is not instantiated properly, therefore when you call w.Create()
(which you shouldn't since a.Start()
has failed) there's a panic.
Therefore the first thing you should do is add return
everywhere needed.
Second, a.Start()
seems to fail because of a network issue (dial tcp 13.234.176.102:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
) therefore you need to check that on your machine.
Ok Quentin,
Thanks a lot for the replies.
Yes, I am working with network interfaces in the same code, I think that is causing this issue.
Cheers