Hey @GuillaumeGautreau ,
Now I am confused
As I said before, your second version of the code ran nicely, and then you asked me again, and then I double-checked it, and then I got this:
➜ UCM-3.0 git:(master) ✗ npm start
> ucm-3.0@0.5.2 start
> node ./bin/www
Your application is listening on port 3310.
node:internal/process/promises:225
triggerUncaughtException(err, true /* fromPromise */);
^
RequestError: Timeout awaiting 'request' for 3500ms
at ClientRequest.<anonymous> (/Users/fabio.marconi/projects/forest-backend/UCM-3.0/node_modules/got/dist/source/core/index.js:956:65)
at Object.onceWrapper (node:events:483:26)
at ClientRequest.emit (node:events:388:22)
at ClientRequest.origin.emit (/Users/fabio.marconi/projects/forest-backend/UCM-3.0/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
at TLSSocket.socketErrorListener (node:_http_client:490:9)
at TLSSocket.emit (node:events:376:20)
at emitErrorNT (node:internal/streams/destroy:188:8)
at emitErrorCloseNT (node:internal/streams/destroy:153:3)
at processTicksAndRejections (node:internal/process/task_queues:80:21)
at Timeout.timeoutHandler [as _onTimeout] (/Users/fabio.marconi/projects/forest-backend/UCM-3.0/node_modules/got/dist/source/core/utils/timed-out.js:36:25)
at listOnTimeout (node:internal/timers:558:17)
at processTimers (node:internal/timers:499:7) {
name: 'TimeoutError',
code: 'ETIMEDOUT',
timings: {
start: 1626099918404,
socket: 1626099918409,
lookup: 1626099921861,
connect: 1626099921904,
secureConnect: undefined,
upload: undefined,
response: undefined,
end: undefined,
error: 1626099921906,
abort: undefined,
phases: {
wait: 5,
dns: 3452,
tcp: 43,
tls: undefined,
request: undefined,
firstByte: undefined,
download: undefined,
total: 3502
}
},
event: 'request'
}
And then I ran it again and again, and I get this:
➜ UCM-3.0 git:(master) ✗ npm start
> ucm-3.0@0.5.2 start
> node ./bin/www
Your application is listening on port 3310.
body {
redirect_uris: [
'http://localhost:3310/admin/forest/authentication/callback'
],
token_endpoint_auth_method: 'none',
application_type: 'web',
grant_types: [ 'authorization_code' ],
response_types: [ 'code' ],
environment_id: 56529,
client_id: 'eyJraWQiOiJ6d0VjbU5LVVpVTkdYUnlNRzZ2blablablabla'
}
Now, it’s intermittent cause sometimes I get TimeoutError
again (first output above).
Actually, it seems that I get TimeoutError
again after a while.
So, what I did was… I appended that code in my app.js
like this:
(async function () {
const Got = require('got');
const got = Got.extend({
followRedirect: false,
headers: {
'User-Agent': 'openid-client/4.2.0 (https://github.com/panva/node-openid-client)'
},
retry: 0,
timeout: 3500,
throwHttpErrors: false
});
const { body } = await got({
headers: {
Authorization: 'Bearer blablablabla'
},
responseType: 'json',
json: {
client_id: undefined,
redirect_uris: [ 'http://localhost:3310/admin/forest/authentication/callback' ],
token_endpoint_auth_method: 'none'
},
url: 'https://api.forestadmin.com/oidc/reg',
method: 'POST'
})
console.log('body', body);
})();
Does it make sense to you?