Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: syscall/js: call of Value.Int on undefined #2

Open
PaulKinlan opened this issue Jul 8, 2019 · 2 comments
Open

panic: syscall/js: call of Value.Int on undefined #2

PaulKinlan opened this issue Jul 8, 2019 · 2 comments

Comments

@PaulKinlan
Copy link

[This isn't a problem with pdfcpu - but I'm looking for some guidance :)]
Hi, firstly I just wanted to say thank you for all the work here, it's help me get mostly up and running.

I have a golang program that has to Stat the file, and I'm getting a heap of errors like you've described but I can't seem to solve. Specifically it seems to fail with 'panic: syscall/js: call of Value.Int on undefined' and the stack trace points to an error when Go system library trys to read atimeMs, which I think is set by retStat.atimeMs = retStat.atime.getTime();

Have you experience any similar problems? I am trying to debug it but not getting amazingly far.

@julianfbeck
Copy link

Hey did you solve this?

@awfulcooking
Copy link

Dropping a note since I found this while trying to find impls of stat() on the JavaScript side.

Have just come from reading setStat in /usr/share/go-1.17/src/syscall/fs_js.go, groaning "oh God, we really do have to set all of those"...

(js.Value.Int() will panic if the JS value isn't a number)

func setStat(st *Stat_t, jsSt js.Value) {
	st.Dev = int64(jsSt.Get("dev").Int())
	st.Ino = uint64(jsSt.Get("ino").Int())
	st.Mode = uint32(jsSt.Get("mode").Int())
	st.Nlink = uint32(jsSt.Get("nlink").Int())
	st.Uid = uint32(jsSt.Get("uid").Int())
	st.Gid = uint32(jsSt.Get("gid").Int())
	st.Rdev = int64(jsSt.Get("rdev").Int())
	st.Size = int64(jsSt.Get("size").Int())
	st.Blksize = int32(jsSt.Get("blksize").Int())
	st.Blocks = int32(jsSt.Get("blocks").Int())
	atime := int64(jsSt.Get("atimeMs").Int())
	st.Atime = atime / 1000
	st.AtimeNsec = (atime % 1000) * 1000000
	mtime := int64(jsSt.Get("mtimeMs").Int())
	st.Mtime = mtime / 1000
	st.MtimeNsec = (mtime % 1000) * 1000000
	ctime := int64(jsSt.Get("ctimeMs").Int())
	st.Ctime = ctime / 1000
	st.CtimeNsec = (ctime % 1000) * 1000000
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants