Does anybody know if it's safe to put `context.waitUntil` on the global to improve it's ergonomics o

Does anybody know if it's safe to put
context.waitUntil
on the global to improve it's ergonomics or does it need to be coupled with a specific request? e.g.
// worker.js
import { myFetch } from './my-fetch';

export default {
  async fetch(request, env, context) {
    global.waitUntil = context.waitUntil;
    return fetch(request);
  },
};

// my-fetch.js
export const fetch = async (request) => {
  const response = await fetch(request); 
  response.headers.append("Cache-Control", "s-maxage=10");
  waitUntil(caches.default.put(request, response.clone()));
  return response;
}
Was this page helpful?