-
Notifications
You must be signed in to change notification settings - Fork 75
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
Error on config results in Error: [object Object]
#29
Comments
The issue is here: https://github.com/absinthe-graphql/absinthe-socket/blob/master/packages/socket/src/pushRequest.js#L43 It seems this should check to see if the response is a map or a string, and call Possibly related to #20 |
I'm trying to create PR that addresses the problem, but I'm new to rollup, prepack, etc. Any chance we could get some contribution guidelines for this repo? |
Below is the comment I wrote in #39:
|
Would you consider a simple solution like wrapping the failing code in a |
I just ran into this error as well, after quite a bit of digging and debugging, I don't think it looks like this should be returning just an Error string. The I discovered this when I attempted to manage errors within my application by using the pretty standard This should likely be returning a payload of In the case of apollo, other apollo-link libraries take in data like this. apollo-link-error handles their return values here. The graphQLErrors field in apollo-link-error relies on the error returned having a value of: Similarly, this logic takes this object and uses it to populate the response field, which passes down and allows for the errors to be returned to the user application for further processing. I made a quick adjustment just for the purposes of local testing to pushRequestUsing.js line 42. if (errorMessage && typeof errorMessage === 'object') {
return abortNotifier(absintheSocket, notifier, { result: errorMessage });
} else {
return abortNotifier(absintheSocket, notifier, createRequestError(errorMessage));
} This works as expected with apollo, successfully returning the data to the application while being compatible with apollo-link. I feel like other non-apollo clients would also be expecting the socket to return a standard |
Just as a side note/update to my previous comment, it looks like apollo-link-http-comon returns an error object with a message and all the relevant data added onto it https://github.com/apollographql/apollo-link/blob/d56fce6f4115dd1d5b304a3593cb69770c971d2b/packages/apollo-link-http-common/src/index.ts#L113. Perhaps a similar pattern could be used here, which would allow for a backwards-compatible message to be provided, while also providing the necessary extra data for consumers of the error? |
Any update on this ticket? It would be really helpful if this gets fixed one way or another. Willing to help! |
The spec says:
Which is what the parent sends (assuming atoms are serialized into strings): {:error, %{errors: [%{locations: [%{column: 0, line: 2}], message: :unauthorized}]}} So this looks like a bug in Absinthe Socket. This prevents proper error handling as there is no way to access the original error data later in the pipeline. I cannot think of a workaround to avoid that as Also, Apollo Client's Http Link handles these errors properly so it's surprising for users adding support for subscriptions to their app: GraphQL errors over HTTP are handled properly but the get an |
It feels like For example, here the errors received by websocket:
But I got I guess for correct errors handling |
Is there any update on this? I made a PR that aims to at least provide useful error messages. But I agree with @alexandrchebotar that the preferred method is probably for @absinthe/socket to not create a new error object so it can be compatible with other links I also noticed someone made a helpful commit to @absinthe/socket to add the original error object to the new error object in the |
I am waiting for a new release for ages now, it seems this repo has become unmaintained.. |
@mgtitimoli I'm happy to contribute to this project and create new releases. Is that something your team would be open to? |
👍 I guess we have to ping the maintainers? @mgtitimoli @tlvenn @bruce |
In the coming days, I will be sending an update that automates the release process, so we can start moving the engines again. |
However regarding to this specific topic, the spec says the message must be string, and there is an extensions field to provide additional context about the error. |
The spec does say that
This is actually what Absinthe Socket should be returning, something like: {errors: [{locations: [{column: 0, line: 2}], message: "unauthorized"}]} I don't think we need extensions for that because the received error is already properly formatted by Absinthe. Currently, the error is lost and there is no way for applications to get it (e.g. to log it or send it to an error tracking platform like Sentry). WDYT? |
Issue
When attempting to return unauthorized from a config macro, the socket impl throws an error of the stringified errors map.
Although
onSubscriptionResponse
maps errors, if an error map is returned on join, the error is not handled correctly.Actual
Results in the following for GraphiQL
Expected
Error maps are handled properly using
gqlErrorsToString
The text was updated successfully, but these errors were encountered: