Skip to content

Commit

Permalink
fix(client): queue status path
Browse files Browse the repository at this point in the history
  • Loading branch information
drochetti committed Oct 27, 2023
1 parent 4797a8d commit 42df050
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion libs/client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@fal-ai/serverless-client",
"description": "The fal serverless JS/TS client",
"version": "0.4.0",
"version": "0.4.1",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
16 changes: 5 additions & 11 deletions libs/client/src/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export async function subscribe<Input, Output>(
if (options.onEnqueue) {
options.onEnqueue(requestId);
}
const path = options.path ?? '';
return new Promise<Output>((resolve, reject) => {
let timeoutId: ReturnType<typeof setTimeout>;
const pollInterval = options.pollInterval ?? 1000;
Expand All @@ -135,15 +134,14 @@ export async function subscribe<Input, Output>(
const requestStatus = await queue.status(id, {
requestId,
logs: options.logs ?? false,
path,
});
if (options.onQueueUpdate) {
options.onQueueUpdate(requestStatus);
}
if (requestStatus.status === 'COMPLETED') {
clearTimeout(timeoutId);
try {
const result = await queue.result<Output>(id, { requestId, path });
const result = await queue.result<Output>(id, { requestId });
resolve(result);
} catch (error) {
reject(error);
Expand Down Expand Up @@ -194,10 +192,6 @@ type BaseQueueOptions = {
* The unique identifier for the enqueued request.
*/
requestId: string;
/**
* The path to the function, if any. Defaults to ``.
*/
path?: string;
};

type QueueStatusOptions = BaseQueueOptions & {
Expand Down Expand Up @@ -268,23 +262,23 @@ export const queue: Queue = {
},
async status(
id: string,
{ requestId, logs = false, path = '' }: QueueStatusOptions
{ requestId, logs = false }: QueueStatusOptions
): Promise<QueueStatus> {
return run(id, {
method: 'get',
path: `/fal/queue/requests/${requestId}/status${path}`,
path: `/fal/queue/requests/${requestId}/status`,
input: {
logs: logs ? '1' : '0',
},
});
},
async result<Output>(
id: string,
{ requestId, path = '' }: BaseQueueOptions
{ requestId }: BaseQueueOptions
): Promise<Output> {
return run(id, {
method: 'get',
path: `/fal/queue/requests/${requestId}/response${path}`,
path: `/fal/queue/requests/${requestId}/response`,
});
},
subscribe,
Expand Down

0 comments on commit 42df050

Please sign in to comment.