Skip further processing if `server-actions` transform emitted any errors

After iterating through all module items, we should check if any errors
were emitted. If errors are present, we should skip any further
processing to avoid unnecessary work.
parent 5b62dd85
...@@ -1776,6 +1776,11 @@ impl<C: Comments> VisitMut for ServerActions<C> { ...@@ -1776,6 +1776,11 @@ impl<C: Comments> VisitMut for ServerActions<C> {
} }
} }
// If there were any errors, skip further processing.
if HANDLER.with(|handler| handler.has_errors()) {
return;
}
if in_action_file || in_cache_file && !self.config.is_react_server_layer { if in_action_file || in_cache_file && !self.config.is_react_server_layer {
self.reference_ids_by_export_name.extend( self.reference_ids_by_export_name.extend(
self.server_reference_exports self.server_reference_exports
......
/* __next_internal_client_entry_do_not_use__ default auto */ export default function App() { /* __next_internal_client_entry_do_not_use__ default auto */
async function fn() {
'use server';
}
return <div>App</div>;
}
/* __next_internal_client_entry_do_not_use__ default auto */ export default function App() { /* __next_internal_client_entry_do_not_use__ default auto */
async function fn() {
'use cache';
}
return <div>App</div>;
}
/* __next_internal_action_entry_do_not_use__ {"00ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { registerServerReference } from "private-next-rsc-server-reference";
export function foo() {}
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([
foo
]);
registerServerReference(foo, "00ab21efdafbe611287bc25c0462b1e0510d13e48b", null);
import 'react'; // ^Tools like Prettier sometimes do this.
'use sevrer' // ^Tools like Prettier sometimes do this.
;
/* __next_internal_client_entry_do_not_use__ foo auto */ const { createProxy } = require("private-next-rsc-mod-ref-proxy"); /* __next_internal_client_entry_do_not_use__ foo auto */
module.exports = createProxy("/app/item.js");
/* __next_internal_client_entry_do_not_use__ foo auto */ const { createProxy } = require("private-next-rsc-mod-ref-proxy"); /* __next_internal_client_entry_do_not_use__ foo auto */
module.exports = createProxy("/app/item.js");
export default function Default() {}
export function foo() {}
export const bar = ()=>{};
/* __next_internal_action_entry_do_not_use__ {"00ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { registerServerReference } from "private-next-rsc-server-reference";
'use strict';
export function bar() {}
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([
bar
]);
registerServerReference(bar, "00ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null);
async function a() {
// this is not allowed here
this.foo();
// arguments is not allowed here
console.log(arguments);
const b = async ()=>{
// this is not allowed here
this.foo();
// arguments is not allowed here
console.log(arguments);
};
function c() {
// this is allowed here
this.foo();
// arguments is allowed here
console.log(arguments);
const d = ()=>{
// this is allowed here
this.foo();
// arguments is allowed here
console.log(arguments);
};
const e = async ()=>{
// this is not allowed here
this.foo();
// arguments is not allowed here
console.log(arguments);
};
}
}
export const api = {
result: null,
product: {
async fetch () {
// this is not allowed here
this.result = await fetch('https://example.com').then((res)=>res.json());
// arguments is not allowed here
console.log(arguments);
}
}
};
// not exported!
async function a() {
// this is allowed here
this.foo();
// arguments is allowed here
console.log(arguments);
const b = async ()=>{
// this is not allowed here
this.foo();
// arguments is not allowed here
console.log(arguments);
};
}
export const obj = {
foo () {
return 42;
},
bar () {
// this is allowed here
this.foo();
// arguments is allowed here
console.log(arguments);
}
};
// exported!
export async function a() {
// this is not allowed here
this.foo();
// arguments is not allowed here
console.log(arguments);
const b = async ()=>{
// this is not allowed here
this.foo();
// arguments is not allowed here
console.log(arguments);
};
function c() {
// this is allowed here
this.foo();
// arguments is allowed here
console.log(arguments);
const d = ()=>{
// this is allowed here
this.foo();
// arguments is allowed here
console.log(arguments);
};
const e = async ()=>{
// this is not allowed here
this.foo();
// arguments is not allowed here
console.log(arguments);
};
}
}
export class MyClass {
async foo() {
'use cache';
return fetch('https://example.com').then((res)=>res.json());
}
async bar() {
'use server';
console.log(42);
}
}
import { BaseClass } from './base';
export class MyClass extends BaseClass {
static async foo() {
// super is allowed here
super.foo();
return fetch('https://example.com').then((res)=>res.json());
}
static async bar() {
if (Math.random() > 0.5) {
// super is not allowed here
return [
super.bar()
];
}
// arguments is not allowed here
console.log(arguments);
// this is not allowed here
return this.foo();
}
}
export async function foo() {
return 'data';
}
export async function bar() {
return 'data';
}
export async function baz() {
return 'data';
}
export async function qux() {
return 'data';
}
export async function quux() {
return 'data';
}
/* __next_internal_client_entry_do_not_use__ foo auto */ const { createProxy } = require("private-next-rsc-mod-ref-proxy"); /* __next_internal_client_entry_do_not_use__ foo auto */
module.exports = createProxy("/app/item.js");
/* __next_internal_client_entry_do_not_use__ foo auto */ const { createProxy } = require("private-next-rsc-mod-ref-proxy"); /* __next_internal_client_entry_do_not_use__ foo auto */
module.exports = createProxy("/app/item.js");
/* __next_internal_action_entry_do_not_use__ {"00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference";
export default $$RSC_SERVER_ACTION_0 = ()=>{};
var $$RSC_SERVER_ACTION_0;
Object["defineProperty"]($$RSC_SERVER_ACTION_0, "name", {
value: "default"
});
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([
$$RSC_SERVER_ACTION_0
]);
registerServerReference($$RSC_SERVER_ACTION_0, "00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null);
/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference";
export const $$RSC_SERVER_ACTION_0 = async function foo() {
'use strict';
};
registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
const foo = $$RSC_SERVER_ACTION_0;
const bar = async ()=>{
const x = 1;
// prettier-ignore
'use server';
};
export default async function Page() {
return <p>hello world</p>;
}
export default async function Page() {
return <p>hello world</p>;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment