Code Monkey home page Code Monkey logo

v8worker2's Introduction

v8worker2

Build Status

This is a minimal binding between Go (golang) and V8 JavaScript. Basic concept is to only expose two methods to JavaScript: send and receive.

V8 Version: 6.9.427.19 (August 2018)

A rather dated presentation on this project

Installing

Due to the complexity of building V8, this package is not buildable with go get.

To install:

go get github.com/ry/v8worker2
cd `go env GOPATH`/src/github.com/ry/v8worker2
./build.py # Will take ~30 minutes to compile.
go test

If you have ccache installed, ./build.py --use_ccache will take advantage of it. This is useful to avoid rebuilding V8 so much.

JavaScript API

The JavaScript interface is exposed thru a single global namespace V8Worker2. The interface has just three methods V8Worker2.print(), V8Worker2.send(), and V8Worker2.recv(). See v8worker2.d.ts for the details.

Golang API

Documentation is at https://godoc.org/github.com/ry/v8worker2 and example usage is at worker_test.go

Difference from the original v8worker

  • The original v8worker passed strings between Go and V8. v8worker2 instead communicates using ArrayBuffer, which is more efficient.

  • The original included recvSync and sendSync methods. These were deemed unnecessary. Now send() can operate both sychronously by returning another ArrayBuffer. Simply return a []byte from the golang recv callback.

  • This version is compatible with modern V8, has a better build setup, and uses Travis for CI.

  • The original prefixed the methods with dollar signs, this version uses a global name space object and provides a typescript declaration file.

License

MIT License. Contributions welcome.

	Copyright 2015-2018 Ryan Dahl <[email protected]>. All rights reserved.

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to
	deal in the Software without restriction, including without limitation the
	rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
	sell copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in
	all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
	IN THE SOFTWARE.

v8worker2's People

Contributors

brandonmanke avatar dlespiau avatar matiasinsaurralde avatar ohsory1324 avatar phated avatar qti3e avatar ry avatar varun1729 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

v8worker2's Issues

Interfacing using a Docker Container

I want to run V8 inside a docker container and run JS inside that container from my GO Program (running inside a different container) by using v8worker2. Any guidance on how I will be able to achieve this?

run ./build.py fetch failed $PATH/depot_tools/.cipd_bin/vpython: No such file or directory

Failed to fetch file gs://chromium-clang-format/0679b295e2ce2fce7919d1e8d003e497475f24a3 for v8/buildtools/mac/clang-format, skipping. [Err: /Users/huanghongjiang/go/src/github.com/ry/v8worker2/depot_tools/vpython: line 42: /Users/huanghongjiang/go/src/github.com/ry/v8worker2/depot_tools/.cipd_bin/vpython: No such file or directory
/Users/huanghongjiang/go/src/github.com/ry/v8worker2/depot_tools/vpython: line 42: exec: /Users/huanghongjiang/go/src/github.com/ry/v8worker2/depot_tools/.cipd_bin/vpython: cannot execute: No such file or directory

Add python verion in readme

I saw you already upgraded build.py to support Python 3, that's great.

However, when I run it under Python 3, I found an error that told me Python 3 was not working here, because depot_tools requires Python 2.7 indeed.

So I think it would be great if you add that info in readme, noticing people that only Python 2 works in this repo.

deferred.ts missing from deno.land

I was attempting to run the advanced example on the website, the deno install goes well but when running the example script getting:

Downloading https://deno.land/x/http/server.ts...
Compiling https://deno.land/x/http/server.ts
Downloading https://deno.land/x/io/bufio.ts...
Downloading https://deno.land/x/textproto/mod.ts...
Downloading https://deno.land/x/http/http_status.ts...
Downloading https://deno.land/x/testing/mod.ts...
Downloading https://deno.land/x/util/deferred.ts... NOT FOUND

Looks like the ts script is missing from the domain itself: https://deno.land/x/util/deferred.ts

Failed to open 'out/v8.pc': No such file or directory

Hi,

I'm getting the following error on macOS 10.13.4:

Nikolais-MBP:~ nonscio$ go get github.com/ry/v8worker2
# pkg-config --cflags out/v8.pc
Failed to open 'out/v8.pc': No such file or directory
No package 'out/v8.pc' found
pkg-config: exit status 1

Do you know what's going on?

Thanks!

error in build window 10

window 10
python 2.7.15

$ ./build.py --use_ccache
out_path None
Rebuilding V8
Fetching dependencies.
Traceback (most recent call last):
  File "./build.py", line 152, in <module>
    main()
  File "./build.py", line 88, in main
    lib_fn = Rebuild()
  File "./build.py", line 100, in Rebuild
    EnsureDeps(v8_path)
  File "./build.py", line 149, in EnsureDeps
    env=env)
  File "C:\Python27\lib\subprocess.py", line 185, in check_call
    retcode = call(*popenargs, **kwargs)
  File "C:\Python27\lib\subprocess.py", line 172, in call
    return Popen(*popenargs, **kwargs).wait()
  File "C:\Python27\lib\subprocess.py", line 394, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 644, in _execute_child
    startupinfo)
WindowsError: [Error 2]

seek help

question for binding.cc

when I embed v8worker2 in my project, I modified a function definition, and it throws symbol not found.

I'm confused with the binding.cc file when was compiled and linked?

I have made a test static library, and slightly change the binding.cc, should I include binding.cc in my go file?

update V8

Could you update V8 to the latest version?

[Doc] build.py only support Python2

build.py used keywords like print that only works in Python2. I think it should be figure out.

And as docs I think more clarify desc will be:

cd `go env GOPATH`/src/github.com/ry
git clone https://github.com/ry/v8worker2.git
cd v8worker2
./build.py
...

First installation with go get will be error not found v8.pc, which generated after exec build.py. This will be confused for beginners.

Depot tools path not found

Hi, I've been experiencing some errors while running the build process suggested in the README.
I'm running macOS Sierra and Python 3.5, I've figured out that the depot_tools path wasn't correctly set:

% ./build.py
Rebuilding V8
Fetching dependencies.
Syncing projects: 100% (24/24), done.                                   
Running hooks: 100% (28/28), done.              
Traceback (most recent call last):
  File "./build.py", line 155, in <module>
    main()
  File "./build.py", line 89, in main
    lib_fn = Rebuild()
  File "./build.py", line 104, in Rebuild
    assert os.path.exists(gn_path)
AssertionError

In my particular case I've found depot_tools under [root_path]/v8/third_party/depot_tools and not [root_path]/depot_tools:

Rebuilding V8
Fetching dependencies.
Syncing projects: 100% (24/24), done.                                   
Running hooks: 100% (28/28), done.              
Running gn
Done. Made 118 targets from 77 files in 471ms
Running ninja
v8_path = /Users/matias/dev/v8worker2/v8
ninja: Entering directory `/Users/matias/dev/v8worker2/out/v8build'
ninja: no work to do.
lib_fn = /Users/matias/dev/v8worker2/out/v8build/obj/libv8_monolith.a
Wrote /Users/matias/dev/v8worker2/v8.pc

Will send a PR adding a flag for overriding depot_tools, it worked fine with me this way and might be useful for other users.

Exception after calling Dispose() or after worker GC

Run this test app:

main.go

package main

import (
	"fmt"

	"github.com/ry/v8worker2"
)

func main() {
	for i := 1; i <= 10; i++ {
		fmt.Println("create worker", i)

		recvCount := 0
		worker := v8worker2.New(func(msg []byte) []byte {
			if len(msg) != 5 {
				fmt.Println("bad msg", msg)
				panic("")
			}
			recvCount++
			return nil
		})

		err := worker.Load("codeWithRecv.js", `
			V8Worker2.recv(function(msg) {
				V8Worker2.print("TestBasic recv byteLength", msg.byteLength);
				if (msg.byteLength !== 3) {
					throw Error("bad message");
				}
			});
		`)
		if err != nil {
			panic(err)
		}
		err = worker.SendBytes([]byte("hii"))
		if err != nil {
			panic(err)
		}
		codeWithSend := `
			V8Worker2.send(new ArrayBuffer(5));
			V8Worker2.send(new ArrayBuffer(5));
		`

		err = worker.Load("codeWithSend.js", codeWithSend)
		if err != nil {
			panic(err)
		}

		if recvCount != 2 {
			fmt.Println("bad recvCount", recvCount)
			panic("")
		}

		worker.TerminateExecution()
		worker.Dispose()
	}
}


Throws this exception:

create worker 1
TestBasic recv byteLength 3
main(52501,0x1226d5c0) malloc: *** error for object 0x8002470: pointer being freed was not allocated
main(52501,0x1226d5c0) malloc: *** set a breakpoint in malloc_error_break to debug
SIGABRT: abort
PC=0x7fff5a5e923e m=0 sigcode=0

goroutine 0 [idle]:
runtime: unknown pc 0x7fff5a5e923e
stack: frame={sp:0x7ffeefbff658, fp:0x0} stack=[0x7ffeefb80988,0x7ffeefbff9f0)
00007ffeefbff558:  0000000000000000  00007fff5a679b1e 
00007ffeefbff568:  00007ffeefbff5b8  00007ffeefbff5e0 
00007ffeefbff578:  00000000053fc000  000000001226d5c0 
00007ffeefbff588:  00007ffeefbffbe4  00007fff5a679aa9 
00007ffeefbff598:  0000000000000050  00007ffeefbff680 
00007ffeefbff5a8:  00007fff5a693085  0000003000000018 
00007ffeefbff5b8:  00007ffeefbff690  00007ffeefbff5d0 
00007ffeefbff5c8:  00007fff5a6931d9  0000000000000000 
00007ffeefbff5d8:  0000000000000050  00007fff5a679aa9 
00007ffeefbff5e8:  00000000053fc047  0000000000000000 
00007ffeefbff5f8:  0000000000000000  00007ffeefbff7e8 
00007ffeefbff608:  00007ffeefbff678  0000000000000000 
00007ffeefbff618:  00000000053fb000  00007ffeefbff648 
00007ffeefbff628:  0000000000000050  00007fff8d292240 
00007ffeefbff638:  00007fff8d291ca0  00007fff5a53148c 
00007ffeefbff648:  0000000000000000  00007ffeefbff690 
00007ffeefbff658: <00007fff5a69fc1c  000000001226d5c0 
00007ffeefbff668:  00007ffeefbff6a8  0000000000000000 
00007ffeefbff678:  00000000053fb000  0000000000000000 
00007ffeefbff688:  0000000000000050  00007ffeefbff6c0 
00007ffeefbff698:  00007fff5a5521c9  00007fff8d2a260c 
00007ffeefbff6a8:  00000000ffffffdf  ffffffff00000000 
00007ffeefbff6b8:  00000000053fb028  00007ffeefbff720 
00007ffeefbff6c8:  00007fff5a6616e2  0000000000000000 
00007ffeefbff6d8:  000000001226d5c0  00007ffeefbff7e0 
00007ffeefbff6e8:  0000000000000000  00007fff5a677a5b 
00007ffeefbff6f8:  0000000008014720  000000000000000a 
00007ffeefbff708:  0000000008003000  0000000008014720 
00007ffeefbff718:  0000000000000003  00007ffeefbff800 
00007ffeefbff728:  00007fff5a6614a3  00007ffeefbff7c0 
00007ffeefbff738:  00007fff5a65bb54  0000000008002470 
00007ffeefbff748:  00000000053aba00  0000000008000000 
runtime: unknown pc 0x7fff5a5e923e
stack: frame={sp:0x7ffeefbff658, fp:0x0} stack=[0x7ffeefb80988,0x7ffeefbff9f0)
00007ffeefbff558:  0000000000000000  00007fff5a679b1e 
00007ffeefbff568:  00007ffeefbff5b8  00007ffeefbff5e0 
00007ffeefbff578:  00000000053fc000  000000001226d5c0 
00007ffeefbff588:  00007ffeefbffbe4  00007fff5a679aa9 
00007ffeefbff598:  0000000000000050  00007ffeefbff680 
00007ffeefbff5a8:  00007fff5a693085  0000003000000018 
00007ffeefbff5b8:  00007ffeefbff690  00007ffeefbff5d0 
00007ffeefbff5c8:  00007fff5a6931d9  0000000000000000 
00007ffeefbff5d8:  0000000000000050  00007fff5a679aa9 
00007ffeefbff5e8:  00000000053fc047  0000000000000000 
00007ffeefbff5f8:  0000000000000000  00007ffeefbff7e8 
00007ffeefbff608:  00007ffeefbff678  0000000000000000 
00007ffeefbff618:  00000000053fb000  00007ffeefbff648 
00007ffeefbff628:  0000000000000050  00007fff8d292240 
00007ffeefbff638:  00007fff8d291ca0  00007fff5a53148c 
00007ffeefbff648:  0000000000000000  00007ffeefbff690 
00007ffeefbff658: <00007fff5a69fc1c  000000001226d5c0 
00007ffeefbff668:  00007ffeefbff6a8  0000000000000000 
00007ffeefbff678:  00000000053fb000  0000000000000000 
00007ffeefbff688:  0000000000000050  00007ffeefbff6c0 
00007ffeefbff698:  00007fff5a5521c9  00007fff8d2a260c 
00007ffeefbff6a8:  00000000ffffffdf  ffffffff00000000 
00007ffeefbff6b8:  00000000053fb028  00007ffeefbff720 
00007ffeefbff6c8:  00007fff5a6616e2  0000000000000000 
00007ffeefbff6d8:  000000001226d5c0  00007ffeefbff7e0 
00007ffeefbff6e8:  0000000000000000  00007fff5a677a5b 
00007ffeefbff6f8:  0000000008014720  000000000000000a 
00007ffeefbff708:  0000000008003000  0000000008014720 
00007ffeefbff718:  0000000000000003  00007ffeefbff800 
00007ffeefbff728:  00007fff5a6614a3  00007ffeefbff7c0 
00007ffeefbff738:  00007fff5a65bb54  0000000008002470 
00007ffeefbff748:  00000000053aba00  0000000008000000 

goroutine 1 [syscall]:
runtime.cgocall(0x4096390, 0xc000055e90, 0x8)
	/usr/local/Cellar/go/1.11.4/libexec/src/runtime/cgocall.go:128 +0x5e fp=0xc000055e60 sp=0xc000055e28 pc=0x40045be
github.com/ry/v8worker2._Cfunc_worker_dispose(0x8001e30)
	_cgo_gotypes.go:125 +0x41 fp=0xc000055e90 sp=0xc000055e60 pc=0x4094591
github.com/ry/v8worker2.(*Worker).Dispose.func1(0x8001e30)
	/Users/gabeshahbazian/development/go/src/github.com/ry/v8worker2/worker.go:194 +0x56 fp=0xc000055ec8 sp=0xc000055e90 pc=0x4095736
github.com/ry/v8worker2.(*Worker).Dispose(0xc0000101f0)
	/Users/gabeshahbazian/development/go/src/github.com/ry/v8worker2/worker.go:194 +0x98 fp=0xc000055ef8 sp=0xc000055ec8 pc=0x40950b8
main.main()
	/Users/gabeshahbazian/development/go/src/github.com/gshahbazian/v8test/main.go:54 +0x52 fp=0xc000055f98 sp=0xc000055ef8 pc=0x4095dd2
runtime.main()
	/usr/local/Cellar/go/1.11.4/libexec/src/runtime/proc.go:201 +0x207 fp=0xc000055fe0 sp=0xc000055f98 pc=0x402b277
runtime.goexit()
	/usr/local/Cellar/go/1.11.4/libexec/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc000055fe8 sp=0xc000055fe0 pc=0x4053851

rax    0x0
rbx    0x1226d5c0
rcx    0x7ffeefbff658
rdx    0x0
rdi    0x307
rsi    0x6
rbp    0x7ffeefbff690
rsp    0x7ffeefbff658
r8     0x0
r9     0x7ffeefbff5b0
r10    0x0
r11    0x206
r12    0x307
r13    0x53fb000
r14    0x6
r15    0x2d
rip    0x7fff5a5e923e
rflags 0x206
cs     0x7
fs     0x0
gs     0x0
exit status 2

Platform: macOS 10.14.2

Note: built against v8 6.9.427.19 as suggested here: #22

Error in build, assert error

OS: macOS 10.13

Traceback (most recent call last):
  File "./build.py", line 152, in <module>
    main()
  File "./build.py", line 88, in main
    lib_fn = Rebuild()
  File "./build.py", line 103, in Rebuild
    assert os.path.exists(gn_path)
AssertionError

Error building on macOS 10.14

OS: macOS 10.14
Python 2.7.15

I was getting this build error building on macOS 10.14:

Running gn
********************************************************************************
 WARNING: The Mac OS X SDK is incompatible with the version of Xcode. To fix,
          either upgrade Xcode to the latest version or install the Mac OS X
          10.12 SDK. For more information, see https://crbug.com/620127.

 Current SDK Version:   10.14
 Current Xcode Version: 0101 (10B61)
********************************************************************************
ERROR at //build/config/mac/mac_sdk.gni:98:3: Assertion failed.
  assert(false, "SDK is incompatible with Xcode")
  ^-----
SDK is incompatible with Xcode
See //build/toolchain/mac/BUILD.gn:14:1: whence it was imported.
import("//build/config/mac/mac_sdk.gni")
^--------------------------------------
See //BUILD.gn:621:1: which caused the file to be included.
action("js2c") {
^---------------
Traceback (most recent call last):
  File "./build.py", line 152, in <module>
    main()
  File "./build.py", line 88, in main
    lib_fn = Rebuild()
  File "./build.py", line 117, in Rebuild
    env=env)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/brandon/Documents/projects/v8worker2/depot_tools/gn', 'gen', '/Users/brandon/Documents/projects/v8worker2/out/v8build', '--args=   is_component_build=false   is_debug=false   libcpp_is_static=false   symbol_level=1   treat_warnings_as_errors=false   use_custom_libcxx=false   use_sysroot=false   v8_deprecation_warnings=false   v8_embedder_string="-v8worker2"   v8_enable_gdbjit=false   v8_enable_i18n_support=false   v8_enable_test_features=false   v8_experimental_extra_library_files=[]   v8_extra_library_files=[]   v8_imminent_deprecation_warnings=false   v8_monolithic=true   v8_static_library=false   v8_target_cpu="x64"   v8_untrusted_code_mitigations=false   v8_use_external_startup_data=false   v8_use_snapshot=true ']' returned non-zero exit status 1

After doing some digging [1] it seemed to be because v8 version 6.8 is incompatible with the most recent version of Xcode. To fix this I ended up updating to v8 6.9.427.19 (commit aae2791) which patched this issue.

I can submit a PR if this seems like something worth fixing?

[1] Homebrew/homebrew-core#31616

Get error when building

I have Python 3 installed on my system.

~/go/src/github.com/ry/v8worker2
❯ ./build.py --use_ccache
out_path None
Rebuilding V8
Fetching dependencies.
depot_tools update failed. Conflict in /Users/nikivi/go/src/github.com/ry/v8worker2/depot_tools
/Users/nikivi/go/src/github.com/ry/v8worker2/.git/modules/depot_tools/rebase-apply/patch:56: trailing whitespace.

/Users/nikivi/go/src/github.com/ry/v8worker2/.git/modules/depot_tools/rebase-apply/patch:71: trailing whitespace.

/Users/nikivi/go/src/github.com/ry/v8worker2/.git/modules/depot_tools/rebase-apply/patch:73: trailing whitespace.
Windows only).
/Users/nikivi/go/src/github.com/ry/v8worker2/.git/modules/depot_tools/rebase-apply/patch:77: trailing whitespace.

/Users/nikivi/go/src/github.com/ry/v8worker2/.git/modules/depot_tools/rebase-apply/patch:225: trailing whitespace.

warning: squelched 596 whitespace errors
warning: 601 lines add whitespace errors.
error: Failed to merge in the changes.
Patch failed at 0001 Create the Next Generation of depot_tools. Eh.
The copy of the patch that failed is found in: /Users/nikivi/go/src/github.com/ry/v8worker2/.git/modules/depot_tools/rebase-apply/patch

Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
Running gn
gn.py: Could not find checkout in any parent of the current path.
This must be run inside a checkout.
Traceback (most recent call last):
  File "./build.py", line 149, in <module>
    main()
  File "./build.py", line 85, in main
    lib_fn = Rebuild()
  File "./build.py", line 114, in Rebuild
    env=env)
  File "/nix/store/10f4qxb00wk9j6cicd9h1qzwqgnc36ji-python-2.7.14/lib/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/nikivi/go/src/github.com/ry/v8worker2/depot_tools/gn', 'gen', '/Users/nikivi/go/src/github.com/ry/v8worker2/out/v8build', '--args=   is_component_build=false   is_debug=false   libcpp_is_static=false   symbol_level=1   treat_warnings_as_errors=false   use_custom_libcxx=false   use_sysroot=false   v8_deprecation_warnings=false   v8_embedder_string="-v8worker2"   v8_enable_gdbjit=false   v8_enable_i18n_support=false   v8_enable_test_features=false   v8_experimental_extra_library_files=[]   v8_extra_library_files=[]   v8_imminent_deprecation_warnings=false   v8_monolithic=true   v8_static_library=false   v8_target_cpu="x64"   v8_untrusted_code_mitigations=false   v8_use_external_startup_data=false   v8_use_snapshot=true  cc_wrapper="/Users/nikivi/.nix-profile/bin/ccache"']' returned non-zero exit status 1

v8 did not contain fe12316e...

when I clone the v8worker2 code, and get the submodule, it failed with:

> git submodule update --init --recursive 

Cloning into '/home/xxx/Workspace/go/src/github.com/ry/v8worker2/depot_tools'...
Cloning into '/home/xxx/Workspace/go/src/github.com/ry/v8worker2/v8'...
remote: Counting objects: 26439, done
remote: Finding sources: 100% (26439/26439)
remote: Total 26439 (delta 16997), reused 26425 (delta 16997)
Receiving objects: 100% (26439/26439), 32.11 MiB | 5.99 MiB/s, done.
Resolving deltas: 100% (16997/16997), done.
From https://chromium.googlesource.com/chromium/tools/depot_tools
 * branch              f16fdf3165b8b86d10386d18a6b6075169c10e15 -> FETCH_HEAD
Submodule path 'depot_tools': checked out 'f16fdf3165b8b86d10386d18a6b6075169c10e15'
error: no such remote ref fe12316ec4b4a101923e395791ca55442e62f4cc
Fetched in submodule path 'v8', but it did not contain fe12316ec4b4a101923e395791ca55442e62f4cc. Direct fetching of that commit failed.

how to fix this?

thanks very much!

GO111MODULE=on seems to break install

I'm having some trouble installing the package. I'm using the go get command but with the -d flag. I'm on OSX and noticed that the package doesn't make its way to my $GOHOME/src path. instead it's installed into the src/mod/cache.

I assume it's safer to just clone the package and run the install directly?

Allocating a few MB in V8Worker2.recv crashes when looping worker.SendBytes

Run this test app:

main.go

package main

import (
	"github.com/ry/v8worker2"
)

func main() {
	worker := v8worker2.New(func(msg []byte) []byte {
		return nil
	})

	err := worker.Load("codeWithRecv.js", `
		V8Worker2.recv(function(msg) {
			var data = new ArrayBuffer(5600000)
		})
	`)
	if err != nil {
		panic(err)
	}

	for i := 0; i <= 1000; i++ {
		err = worker.SendBytes([]byte(`test`))
		if err != nil {
			panic(err)
		}
	}
}


Throws this exception:

main(56725,0x70001067a000) malloc: *** error for object 0x60028e0: pointer being freed was not allocated
main(56725,0x70001067a000) malloc: *** set a breakpoint in malloc_error_break to debug
signal: abort trap

Platform: macOS 10.14.2

Note: built against v8 6.9.427.19 as suggested here: #22

CompileModule?

First of all, I wanted to say thank you for this project (and v1)! I am super excited about it and have been following for a long time.

Anyway, what would think about using ScriptCompiler::CompileModule instead of Script::Compile? I did some experiments at https://github.com/phated/v8worker2/blob/modules/binding.cc#L252-L271 (Please note that I don't know C at all, so it's probably terrible code.) because I didn't understand why import/export were invalid syntax.

Maybe it makes sense as a separate API? I also wonder if CompileModule works any differently from Compile for script-style JS code.

Running webassembly code

Thank you for the work you've put into this library. Love the simplicity! I was wondering if it is possible to run webassembly code? I'm researching the possibility of running untrusted code in a v8 isolate. This approach is written down here: https://blog.cloudflare.com/cloud-computing-without-containers

The possibility of running any code that compiles to webassembly through your simple v8 interface really excites me! Is this possible, or easily added?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.