Skip to content

Commit

Permalink
don't waituntil in http server
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzmatazzz committed Aug 11, 2024
1 parent 1fbb178 commit 7e5299f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/*import getYoga from './graphql-yoga.mjs';
import getYoga from './graphql-yoga.mjs';
import graphQLOptions from './utils/graphql-options.mjs';

export default {
Expand All @@ -12,8 +12,8 @@ export default {
return new Response(graphQLOptions.debug ? err : 'Something went wrong', { status: 500 });
}
},
};*/
import { graphql } from 'graphql';
};
/*import { graphql } from 'graphql';
import { v4 as uuidv4 } from 'uuid';
import DataSource from './datasources/index.mjs';
Expand Down Expand Up @@ -242,4 +242,4 @@ export default {
return new Response(graphQLOptions.debug ? err : 'Something went wrong', { status: 500 });
}
},
};
};*/
5 changes: 3 additions & 2 deletions plugins/plugin-nightbot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const usePaths = [
];

export async function getNightbotResponse(request, url, env, serverContext) {
console.log('serverContext', Object.keys(serverContext));
if (request.method.toUpperCase() !== 'GET') {
return new Response(null, {
status: 405,
Expand Down Expand Up @@ -75,9 +76,9 @@ export async function getNightbotResponse(request, url, env, serverContext) {
// using waitUntil doens't hold up returning a response but keeps the worker alive as long as needed
if (request.ctx?.waitUntil) {
request.ctx.waitUntil(putCachePromise);
} else if (serverContext.waitUntil) {
} /*else if (serverContext.waitUntil) {
serverContext.waitUntil(putCachePromise);
}
}*/
}
return new Response(responseBody)
}
Expand Down
5 changes: 4 additions & 1 deletion plugins/plugin-use-cache-machine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export default function useCacheMachine(env) {
// using waitUntil doesn't hold up returning a response but keeps the worker alive as long as needed
const cacheBody = JSON.stringify(result);
if (cacheBody.length > 0) {
request.ctx.waitUntil(cacheMachine.put(env, request.params.query, request.params.variables, cacheBody, String(ttl), sCache));
const cachePut = cacheMachine.put(env, request.params.query, request.params.variables, cacheBody, String(ttl), sCache);
if (typeof process === 'undefined') {
request.ctx.waitUntil(cachePut);
}
} else {
console.warn('Skipping cache for zero-length response');
console.log(`Request method: ${request.method}`);
Expand Down

0 comments on commit 7e5299f

Please sign in to comment.