Skip to content
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

fix: 🐛 token too long in http headers #410

Merged
merged 1 commit into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/conditor/src/corhal-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import each from 'async-each-series';
const request = (url, parameters) => async () => {
const response = await fetch(url, parameters);
if (!response.ok) {
throw new Error(response.statusText);
const err = new Error(response.statusText);
err.body = await response.json();
throw err;
}
return response;
};
Expand Down Expand Up @@ -69,7 +71,7 @@ export default async function CORHALFetch(data, feed) {
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
body: JSON.stringify({ ...data, envelope: true }),
};
const options = {
retries,
Expand Down Expand Up @@ -100,7 +102,7 @@ export default async function CORHALFetch(data, feed) {
const { headers: headersBis, body: noticesBis } = await responseBis.json();
loop(stream, noticesBis, headersBis['after-key-token']);
} catch (e) {
console.error(`Error with ${url}/after/`, e.message);
console.error(`Error with ${url}/after/`, e.message, e.body);
stream.end();
}
} else {
Expand All @@ -110,8 +112,7 @@ export default async function CORHALFetch(data, feed) {
try {
const output = ezs.createStream(ezs.objectMode());
const response = await retry(request(cURL.href, parameters), options);
const headers = response.headers.raw();
const notices = await response.json();
const { headers, body: notices } = await response.json();
await loop(output, notices, headers['after-key-token']);
await feed.flow(output);
} catch (e) {
Expand Down
Loading