Commit d62e225
committed
fix: use global singleton for Sass transpiler to prevent CI errors
Fixes #90
Changes the Sass transpiler from per-Manager lazy initialization to a
global singleton with lazy initialization. This prevents race conditions
and resource issues when Sites are reloaded during watch mode or when
multiple Manager instances are created.
Root Cause:
- Each renderers.Manager previously had its own sassTranspiler field
- When watch mode detects changes requiring a full reload (e.g., _config.yml
changes), a new Site instance is created with a new Manager
- The old Manager's transpiler was never closed, leading to abandoned
Dart Sass child processes
- In CI environments, this caused "connection is shut down" and
"unexpected EOF" errors when the stdin/stdout streams were closed
unexpectedly during process shutdown/startup overlap
Solution:
- Move to a package-level global singleton transpiler with lazy init
- Aligns with godartsass recommendation: "create one and use that for
all the SCSS processing needed"
- The transpiler is thread-safe and stateless (include paths are passed
to Execute()), so a single instance can safely serve all Managers
Testing:
- Added site/testdata/site1/assets/css/main.scss for regression testing
- Updated site/drop_test.go to account for new test file
- All tests pass, linting passes
- Verified SCSS compilation works correctly1 parent f7f3017 commit d62e225
3 files changed
Lines changed: 38 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
17 | 27 | | |
18 | 28 | | |
19 | 29 | | |
| |||
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
34 | 41 | | |
35 | 42 | | |
36 | 43 | | |
| |||
175 | 182 | | |
176 | 183 | | |
177 | 184 | | |
178 | | - | |
179 | | - | |
180 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
181 | 188 | | |
182 | | - | |
183 | | - | |
| 189 | + | |
| 190 | + | |
184 | 191 | | |
185 | | - | |
| 192 | + | |
186 | 193 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments