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

Avoid error in type signature for Context.Isolate, NewObjectTemplate & NewFunctionTemplate #152

Merged
merged 6 commits into from
Sep 2, 2021

Conversation

dylanahsmith
Copy link
Collaborator

Fixes #108

The above issue linked to #118 (comment) where it was decided that panic may be more appropriate and idiomatic Go code in certain cases

Specifically, this makes sense when:

  • there is no underlying error in the v8 API used
  • any error can be equivalently checked in the caller
  • the error typically represents a bug in the caller

As such, I removed error from the type signature of:

  • Context.Isolate
  • NewObjectTemplate
  • NewFunctionTemplate

@codecov
Copy link

codecov bot commented Jul 6, 2021

Codecov Report

Merging #152 (f50ba33) into master (a674d15) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #152   +/-   ##
=======================================
  Coverage   96.91%   96.91%           
=======================================
  Files          12       12           
  Lines         454      454           
=======================================
  Hits          440      440           
  Misses          9        9           
  Partials        5        5           
Impacted Files Coverage Δ
promise.go 100.00% <ø> (ø)
context.go 94.59% <100.00%> (ø)
function_template.go 100.00% <100.00%> (ø)
object_template.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a674d15...f50ba33. Read the comment docs.

@dylanahsmith
Copy link
Collaborator Author

An example that highlights the need for this change is that code using NewContext to create the isolate (e.g. ctx, err := v8go.NewContext()). If that succeeds, the code would be expected to close the context and dispose of the isolate to avoid a memory leak. However, the error return value prevents the isolate from being disposed of unconditionally using defer ctx.Isolate().Dispose().

@wisepythagoras
Copy link
Contributor

@dylanahsmith It looks like @rogchap doesn't really care about this project anymore, so in the coming days I'll be pulling all your PRs into my forked branch to - hopefully - continue development there.

@dylanahsmith
Copy link
Collaborator Author

I talked to @rogchap on the v8go slack channel and it isn't that he doesn't care about this project, he has just been preoccupied.

For now, I would recommend continuing to contribute changes to this repo and using a fork to pull in any features blocking your work. That is the approach we are taking. In the case of this PR, it isn't a feature that is needed to unblock anything.

@wisepythagoras
Copy link
Contributor

Thanks for the clarification. I didn't realize that there was a Slack channel about this. Sounds good!

@rogchap rogchap merged commit 5d44982 into rogchap:master Sep 2, 2021
@dylanahsmith dylanahsmith deleted the avoid-some-error-returns branch September 3, 2021 13:12
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

Successfully merging this pull request may close these issues.

Consider using panic
4 participants