Skip to content

Commit aad4eda

Browse files
committed
Add a comment to explain fsCall() safety checks
1 parent ce5430d commit aad4eda

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

compiler/natives/src/syscall/fs_js.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ func fsCall(name string, args ...interface{}) (js.Value, error) {
2222
f := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
2323
var res callResult
2424

25+
// Check that args has at least one element, then check both IsUndefined() and IsNull() on
26+
// that element. In some situations, BrowserFS calls the callback without arguments or with
27+
// an undefined argument: https://github.com/gopherjs/gopherjs/pull/1118
2528
if len(args) >= 1 {
2629
if jsErr := args[0]; !jsErr.IsUndefined() && !jsErr.IsNull() {
2730
res.err = mapJSError(jsErr)

0 commit comments

Comments
 (0)