After an http request, the callback does not return and a deadlock occurs.
lock The inner block is not reached.
The action function cannot be called, so the callback cannot be received.
Schema : Update Script Test
function request(method, url, body, headers) {
return new Promise((resolve, reject) => {
try {
if (method === 'GET') {
getJSON(url, (data) => {
resolve(data);
}, headers, true);
}
else if (method === 'POST') {
postJSON(url, body, (data) => {
resolve(data);
}, headers, true);
}
else if (method === 'PUT') {
putJSON(url, body, (data) => {
resolve(data);
}, headers, true);
}
else if (method === 'DELETE') {
deleteJSON(url, (data) => {
resolve(data);
}, headers, true);
} else {
reject('not support requst method');
}
} catch(ex) {
reject(ex);
}
});
}
(async () => {
const headers = {
'Content-Type': `application/json`
};
try {
await request('PUT', 'http://localhost:5000/health', {}, headers);
} catch(ex) {
reject(`xx : ${ex}`);
}
})()strong text