Comments (10)
I refactored our typescript client to dynamically determine the response type. Previously we were statically compiling the response handler into every call but now it just generically always uses the json handler (which can skip json parsing if the body isn't returning the correct content type).
We just rolled a release so it might be a little bit of time before we publish the changes, however I wrote a test to explicitly trigger the issue you were having and it doesn't explode anymore. I'll let you close this whenever you get a chance to verify the changes.
from fusionauth-typescript-client.
Thanks for the report @NickBolles - I want to say we've corrected this behavior.
The 404
status code is correct, but when we receive that status code from FusionAuth, the client should expect the body length to be 0.
If you still encounter this error let us know. Thanks!
from fusionauth-typescript-client.
I'll try it out. Thank you!
from fusionauth-typescript-client.
Thanks for confirming @Snazzypants I'll close
from fusionauth-typescript-client.
What version should be checking to see if this is fixed? I am also seeing this behavior - am on FusionAuth version 1.15.8 and @fusionauth/typescript-client 1.15.4
from fusionauth-typescript-client.
@Snazzypants you get a 404
and the client is attempting to deserialize the body and you see a similar exception as @NickBolles?
Can you provide an example snippet of code and the response or error you're seeing? Thanks.
@tyduptyler13 I was thinking this was something we fixed already. In the case of the Login API, or others - that may return a 404
w/out a body - the client should be able to handle that. Do you want to take a look when you get a free moment? Thanks.
from fusionauth-typescript-client.
@robotdan I haven't tried this again, but this seems like where the error would occur
/**
* A function that returns the JSON form of the response text.
*
* @param response
* @constructor
*/
async function ErrorJSONResponseHandler<ERT>(response: Response): Promise<ClientResponse<ERT>> {
let clientResponse = new ClientResponse<ERT>();
clientResponse.statusCode = response.status;
clientResponse.exception = await response.json();
return clientResponse;
}
Specifically this line:
clientResponse.exception = await response.json();
Edit: although this commit seems promising for a fix.
13511c1 it was also 14 days after opening this issue. Shod have been fixed in 1.15.8 then.
from fusionauth-typescript-client.
I've updated to 1.15.8 and still get this behavior.
Sample code using this library:
export function login(username: string, password: string, applicationId: string, tenantId: string) {
client.setTenantId(tenantId);
const requestBody = {
loginId: username,
password: password,
applicationId
}
return client.login(requestBody)
.then( clientResponse => {
return {success response};
})
.catch( clientResponse => {
console.log(clientResponse)
return {error response}
});
}
With invalid credentials, the console.log output in the catch block:
ClientResponse {
statusCode: 404,
exception: FetchError: invalid json response body at https://[url]/api/login reason: Unexpected end of JSON input
at C:\jnl\app-backend\node_modules\node-fetch\lib\index.js:272:32
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
message: 'invalid json response body at https://[url]/api/login reason: Unexpected end of JSON input',
type: 'invalid-json'
}
}
When I hit the fusionauth server login endpoint directly with a wrong password, it returns a 404 with no body, as expected.
from fusionauth-typescript-client.
@tyduptyler13 can you take a look and see if this is still an issue, or perhaps we have a second issue to resolve?
from fusionauth-typescript-client.
just updated to 1.18.0 and this works great! Thanks! I can't close this issue, but if @NickBolles or @robotdan want to close this, I think that would be appropriate!
from fusionauth-typescript-client.
Related Issues (20)
- Missing JWTManager HOT 1
- User Search by Ids Fails with multiple Ids HOT 9
- Issues with building app with fusionauth-typescript-client HOT 6
- What is the default timeout for the operation ? HOT 1
- UpdateUser Changes the Password Unexpectedly HOT 2
- patchRegistration not working as intended HOT 3
- SDK method to return current access token or refresh it if expired HOT 4
- ClientResponse `exception` key should be defined as `Errors` type instead of `Error`
- retrieveUserByX does not allow specification of a tenant id HOT 5
- Client and API Documentation don't align - searchEntityTypes HOT 2
- client.logout("refreshtokien here") dont work HOT 2
- Issue with domain sync HOT 5
- EventType includes unused types HOT 4
- Missing /oauth2/device_authorize endpoint
- Missing "Complete the Device Authorization Grant Request" method call HOT 1
- searchUsersByIds Badly formats the query, resulting in an error HOT 1
- Add a default timeout that isn't 0 for requests
- Sveltkit or authJS examples HOT 7
- Unexpected Response for `FusionAuthClient#searchUsersByQuery` When Using `sortFields`. HOT 3
- Receiving punycode deprecation warning HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fusionauth-typescript-client.