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

fix(nodejs): only call get_current_error when an error occurred #209

Merged
merged 5 commits into from
Dec 21, 2023

Conversation

berendsliedrecht
Copy link
Contributor

  • Reduce additional calls to get_current_error
  • Added tests for resolving errors for sync and async calls
    • async calls include error handling inside the callback and outside

Signed-off-by: Berend Sliedrecht <sliedrecht@berend.io>
@berendsliedrecht berendsliedrecht force-pushed the reduce-get-error-calls branch 2 times, most recently from a413660 to 4676879 Compare December 19, 2023 17:30
@andrewwhitehead
Copy link
Member

It's possible to keep the Android build on 1.67 by adding "--locked" to the cargo install command for cross: hyperledger/indy-vdr#247

@berendsliedrecht berendsliedrecht force-pushed the reduce-get-error-calls branch 2 times, most recently from ab20d77 to d7bd028 Compare December 19, 2023 18:38
Signed-off-by: Berend Sliedrecht <sliedrecht@berend.io>
@berendsliedrecht
Copy link
Contributor Author

It's possible to keep the Android build on 1.67 by adding "--locked" to the cargo install command for cross: hyperledger/indy-vdr#247

Maybe I am completely blind and missed something, but it does not seem to work.

@andrewwhitehead
Copy link
Member

andrewwhitehead commented Dec 19, 2023

It seems like cross is built successfully built now, but home 0.5.9 is brought in somehow after the aries builder docker image is loaded?

@andrewwhitehead
Copy link
Member

On the other PR I added Cargo.lock after running cargo update, cargo update -p home@0.5.9 --precise 0.5.5 which seems to work.

TimoGlastra
TimoGlastra previously approved these changes Dec 20, 2023
Copy link
Member

@TimoGlastra TimoGlastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this!!

}
const { nativeCallback, id } = toNativeCallbackWithResponse(cb, responseFfiType)
method(nativeCallback, +id)
const errorCode = method(nativeCallback, +id)
if (errorCode !== 0) deallocateCallbackBuffer(+id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be called always?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only be called if an error occurs outside of the callback, otherwise we deallocate the callback inside the callback when it is finished.

Comment on lines 202 to 203
const error = this.getCurrentError()
if (error.code === 0) return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if the error.code does not match errorCode, we should still throw an error (as errroCode was not 0), but make the error message unknown (could be "Unable to extract error message" or something)

reject(new AriesAskarError(JSON.parse(this.getCurrentError()) as AriesAskarErrorObject))
} else {
resolve()
const error = this.getCurrentError()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also pass the errorCode here, to have the logic consistent with nodejs?

this.code = code
this.extra = extra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is extra used nowhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not even set in the native code.

Signed-off-by: Berend Sliedrecht <sliedrecht@berend.io>
Signed-off-by: Berend Sliedrecht <sliedrecht@berend.io>
Signed-off-by: Timo Glastra <timo@animo.id>
@TimoGlastra TimoGlastra merged commit c13e86e into hyperledger:main Dec 21, 2023
5 checks passed
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.

3 participants