Skip to content

Commit

Permalink
Fixed headers handler
Browse files Browse the repository at this point in the history
  • Loading branch information
chamorin committed Aug 2, 2023
1 parent 0be43e9 commit 35a6a9c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const customCounter = prometheus.registerCounter("custom_counter");

command.action(async options => {
// Setup sink for Block Emitter
const {emitter} = await setup(options);
const { emitter } = await setup(options);
console.log("setup")

// Stream Blocks
Expand All @@ -27,7 +27,7 @@ command.action(async options => {

// Start streaming
await emitter.start();
http.server.close()
http.server.close();
console.log("✅ finished");
})
program.parse();
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions src/commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ function handleHeaders(value: string, previous: Headers) {

let headers = new Headers();

for (const header in previous) {
const [key, value] = header;
headers.set(key, value);
}
previous.forEach((value, header) => {
headers.append(header, value);
});

for (const [key, value] of params) {
headers.append(key, value);
Expand Down
3 changes: 1 addition & 2 deletions src/restartInactivitySeconds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ export function onRestartInactivitySeconds(emitter: BlockEmitter, restartInactiv
await setTimeout(CHECK_INACTIVITY_INTERVAL);
checkInactivity();
}
emitter.on("cursor", (cursor, clock) => {
emitter.on("cursor", (_, clock) => {
lastUpdate = now();
console.log(clock.number, emitter.request.stopBlockNum)
if (clock.number >= emitter.request.stopBlockNum - 1n) {
isFinished = true;
};
Expand Down
2 changes: 0 additions & 2 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export async function setup(options: RunOptions) {
// Cursor
const cursor = cursorPath.startsWith("http") ? httpCursor : fileCursor;

console.log(headers);

// Connect Transport
const startCursor = await cursor.readCursor(cursorPath);
const registry = createRegistry(substreamPackage);
Expand Down

0 comments on commit 35a6a9c

Please sign in to comment.