Skip to content

Commit

Permalink
prevent a small gotcha people might run into when migrating
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Sep 6, 2022
1 parent cd7f2ef commit cc6c56f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/kit/src/runtime/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ export async function respond(request, options, state) {
} catch (e) {
const error = coalesce_to_error(e);
return handle_fatal_error(event, options, error);
} finally {
event.cookies.set = () => {
throw new Error('Cannot use `cookies.set(...)` after the response has been generated');
};

event.setHeaders = () => {
throw new Error('Cannot use `setHeaders(...)` after the response has been generated');
};
}
}

Expand Down

0 comments on commit cc6c56f

Please sign in to comment.