Skip to content

Commit

Permalink
Potentially fixing segmentation fault, see #510, #517, #518
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Jul 11, 2022
1 parent 3784167 commit 06d006a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bindings/js/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/tdewolff/minify/bindings/js
go 1.18

require (
github.com/tdewolff/minify/v2 v2.11.12
github.com/tdewolff/minify/v2 v2.12.0
github.com/tdewolff/parse/v2 v2.6.1
)
2 changes: 2 additions & 0 deletions bindings/js/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ github.com/tdewolff/minify/v2 v2.11.11 h1:f8Ux7FpWSYckQQaFLOLrgMGMuyTfzTyA57I46b
github.com/tdewolff/minify/v2 v2.11.11/go.mod h1:NiPwIL/9TtJIYFYOkuz8HUJ/KuRg/kUb21tTp9Baz3k=
github.com/tdewolff/minify/v2 v2.11.12 h1:LwC0+ayfFkLwIwpeun2T35FeUaO3f6XS2bus/QWAnC0=
github.com/tdewolff/minify/v2 v2.11.12/go.mod h1:8mvf+KglD7XurfvvFZDUYvVURy6bA/r0oTvmakXMnyg=
github.com/tdewolff/minify/v2 v2.12.0 h1:ZyvMKeciyR3vzJrK/oHyBcSmpttQ/V+ah7qOqTZclaU=
github.com/tdewolff/minify/v2 v2.12.0/go.mod h1:8mvf+KglD7XurfvvFZDUYvVURy6bA/r0oTvmakXMnyg=
github.com/tdewolff/parse/v2 v2.5.28/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
github.com/tdewolff/parse/v2 v2.5.29 h1:Uf0OtZL9YaUXTuHEOitdo9lD90P0XTwCjZi+KbGChuM=
github.com/tdewolff/parse/v2 v2.5.29/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
Expand Down
2 changes: 1 addition & 1 deletion bindings/js/minify.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ napi_value init(napi_env env, napi_value exports) {
napi_status status;
napi_value fnConfig, fnString, fnFile;

status = napi_add_async_cleanup_hook(env, cleanup, NULL, NULL);
status = napi_add_env_cleanup_hook(env, cleanup, NULL);

status = napi_create_function(env, NULL, 0, config, NULL, &fnConfig);
if (status != napi_ok) {
Expand Down
3 changes: 2 additions & 1 deletion bindings/js/minify.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"regexp"
"strconv"
"time"
"unsafe"

"github.com/tdewolff/minify/v2"
Expand Down Expand Up @@ -166,7 +167,7 @@ func minifyFile(cmediatype, cinput, coutput *C.char) *C.char {

//export minifyCleanup
func minifyCleanup() {
//os.Exit(0)
time.Sleep(10 * time.Millisecond) // fixes Segmentation fault in Node workers
}

func main() {}
2 changes: 1 addition & 1 deletion bindings/js/test/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (isMainThread) {
worker.on('error', reject);
worker.on('exit', (code) => {
if (code !== 0)
reject(new Error(`Worker stopped with exit code ${code}`));
reject(new Error(`Worker stopped with exit code ${code}`));
});
})
if (output != expected) {
Expand Down

0 comments on commit 06d006a

Please sign in to comment.