Skip to content

Commit e6a654f

Browse files
authored
Merge branch 'main' into fix/scaffold-type-after-msg
2 parents cc62506 + b1264da commit e6a654f

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
### Fixes
1616

1717
- [#4886](https://github.com/ignite/cli/pull/4886) Fix chain scaffolding checks.
18+
- [#4889](https://github.com/ignite/cli/pull/4889) Plugin data race.
1819

1920
## [`v29.8.0`](https://github.com/ignite/cli/releases/tag/v29.8.0)
2021

ignite/internal/plugin/execute.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,28 @@ import (
1212
"github.com/ignite/cli/v29/ignite/services/plugin"
1313
)
1414

15+
type synchronizedBuffer struct {
16+
mu sync.Mutex
17+
buf bytes.Buffer
18+
}
19+
20+
func (b *synchronizedBuffer) Write(p []byte) (int, error) {
21+
b.mu.Lock()
22+
defer b.mu.Unlock()
23+
24+
return b.buf.Write(p)
25+
}
26+
27+
func (b *synchronizedBuffer) String() string {
28+
b.mu.Lock()
29+
defer b.mu.Unlock()
30+
31+
return b.buf.String()
32+
}
33+
1534
// Execute starts and executes a plugin, then shutdowns it.
1635
func Execute(ctx context.Context, path string, args []string, options ...plugin.APIOption) (string, error) {
17-
var buf bytes.Buffer
18-
var mu sync.Mutex
36+
var buf synchronizedBuffer
1937
plugins, err := plugin.Load(
2038
ctx,
2139
[]pluginsconfig.Plugin{{Path: path}},
@@ -40,7 +58,5 @@ func Execute(ctx context.Context, path string, args []string, options ...plugin.
4058
}
4159

4260
plugins[0].KillClient()
43-
mu.Lock()
44-
defer mu.Unlock()
4561
return buf.String(), err
4662
}

0 commit comments

Comments
 (0)