-
Notifications
You must be signed in to change notification settings - Fork 25
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
@commercetools/ts-client 2.0 throws javascript error on http error #761
Comments
PS. we (Lab Digital) have a shared slack channel, feel free to reach out to me. |
I see a similiar issue but only when I use the |
Thanks for reporting this issue. Can you provide me with more details on the request that caused this error? if possible a code snippet will also work. Thanks |
Hi @Engerim Can you provide a code snippet that caused this issue, in the mean time I will investigate it to see if I can reproduce it from my end. Thanks once again for reporting this issue. |
Currently working to find the root cause of this issue and I can confirm this issue doesn't exist in version 1.0.0 of the I will continue working to fix it. |
We are working just with a loop of promises where we send over 100 requests and in the promises and we use the concurrency middleware and set the value to 10 and it fails. it is just happening I will try on monday to replicate the issue in a smaller testcase |
This is now fixed, please update to the latest version of the SDK. Thanks |
Hi @ajimae, I am getting the error using the latest 2.0.4 version |
Hi @miticm I would like to know if you experience this error only on version 2.0.4. does it also occur in version prior to 2.0.4, can you check if this error also occur in version 2.0.3? Also, I believe this issue is fixed here and a new patch version was released here as well. You try this fixed version (2.0.2) and let us know if you still experience this error. Thanks |
Hi @ajimae, I also experience this error in 2.0.3 and 2.0.2. I am not using the ConcurrentModificationMiddleware though, so I am not sure if the fix is relevant Thanks |
Hi @miticm Thanks for confirming the issue also exists in other versions of the SDK. I will look into this and make a fix as soon as possible. I will let you know, once it is done. Thanks |
Hi @miticm I have been struggling to reproduce this issue, please can you share the code and configs that triggers this issues? Preferably the client and the function and methods you are calling for making requests. Thank you |
Hi @ajimae,
here is the Client I use
and here is a call example
and it will produce results with TypeError like these
|
Hi @miticm, I have seen the snippets. I will take a look at it today and hopefully get it fixed. Thanks |
Hi @miticm, I have been on this issue for sometime now and I still couldn't reproduce this on my end. The following is the snippet I used for testing: const { ClientBuilder } = require('@commercetools/ts-client');
const { createApiBuilderFromCtpClient } = require('@commercetools/platform-sdk')
const fetch = require('node-fetch');
function _tokenCache(val) {
let initialVal = val
return {
get() {
return initialVal
},
set(value) {
initialVal = value
}
}
}
const tokenCache = _tokenCache({ token, expirationTime })
const projectKey = process.env.CTP_PROJECT_KEY;
const authMiddlewareOptions = {
projectKey,
host: 'https://auth.europe-west1.gcp.commercetools.com',
credentials: {
clientId: process.env.CTP_CLIENT_ID,
clientSecret: process.env.CTP_CLIENT_SECRET
},
tokenCache,
scopes: [`manage_project:${projectKey}`],
httpClient: fetch
}
const httpMiddlewareOptions = {
host: 'https://api.europe-west1.gcp.commercetools.com',
// includeOriginalRequest: true,
// maskSensitiveHeaderData: true,
httpClient: fetch
}
const client = new ClientBuilder()
.withProjectKey(projectKey)
.withAnonymousSessionFlow(authMiddlewareOptions)
.withHttpMiddleware(httpMiddlewareOptions)
.build();
const apiRoot = createApiBuilderFromCtpClient(client).withProjectKey({ projectKey });
async function exec() {
// create store
// return apiRoot
// .stores()
// .post({ body: { key: 'xxx-test-key' } })
// .execute();
// get carts
// return apiRoot
// .inStoreKeyWithStoreKeyValue({ storeKey: 'xxx-test-key' })
// .me()
// .carts()
// .get({
// queryArgs: {
// expand: 'shippingInfo.shippingMethod',
// },
// }).execute();
// create a cart in store
// return apiRoot
// .inStoreKeyWithStoreKeyValue({ storeKey: 'xxx-test-key' })
// .me()
// .carts()
// .post({
// body: {
// currency: 'EUR'
// }
// }).execute();
// get in-store active cart
return apiRoot
.inStoreKeyWithStoreKeyValue({ storeKey: 'xxx-test-key' })
.me()
.activeCart()
.get({
queryArgs: {
expand: 'shippingInfo.shippingMethod'
}
}).execute();
}
exec()
.then(data => {
console.log(data)
}).catch(e => {
console.error(e)
}); This is the error response when the active cart is not found. Click to expand
I would suggest you do one or all the following to see if the issue still persists.
Thank you. |
Hi @miticm, I am now able to reproduce this issue. The issue occurs when the I will raise a PR soon to fix this issue. Thank you. |
This should now be fixed Don't hesitate to reopen if the issue still persists. Thank you. |
Hi @ajimae, the issue still exists after upgrading the packages |
Hi, We made almost a complete rewrite of the internal logic of the v3 SDK, we just made a new (v2.1.0) release. You can try to update to the latest version and let us know if this issue still exists. Thank you. |
Hi, I tried again today, and it works now, thanks |
Describe the bug
I previously run into this issue: #647 but with the latest version (2.0) we now get the following error:
I think this is the relevant line
commercetools-sdk-typescript/packages/sdk-client-v3/src/client/client.ts
Line 179 in b7581b6
To Reproduce
Do a request which returns an error
The text was updated successfully, but these errors were encountered: