Ahmed Moaz Asif
03/16/2022, 8:45 AMnpm start
on windows, everything gets build and deployed fine. However when I do a GraqhQL query, the live lambda environment crashes
Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: Cannot read property 'filename' of undefined","reason":"TypeError: Cannot read property 'filename' of undefined","promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'filename' of undefined"," at process.<anonymous> (D:\\Starlight\\node_modules\\@serverless-stack\\aws-lambda-ric\\src\\index.ts:48:19)"," at process.emit (events.js:375:28)"," at processPromiseRejections (internal/process/promises.js:245:33)"," at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
Works fine on MacOS and LinuxFrank
Frank
Copy codeTypeError: Cannot read property 'filename' of undefined
Ahmed Moaz Asif
03/18/2022, 7:56 AMAhmed Moaz Asif
03/18/2022, 7:57 AMFrank
Ahmed Moaz Asif
03/18/2022, 8:10 AMFrank
TypeError: Cannot read property 'filename' of undefined
Ahmed Moaz Asif
03/21/2022, 5:01 AMimport Note from "../entities/Note";
import { listNotes, createNote, updateNote, deleteNote, getNoteById} from '../libs/services/notes.service'
type AppSyncEvent = {
info: {
fieldName: string;
};
arguments: {
note: Note;
noteId: string;
};
};
export async function handler(
event: AppSyncEvent
): Promise<Note[] | Note | string | null | undefined> {
switch (event.info.fieldName) {
case "listNotes":
console.log('Here there')
return listNotes();
// case "createNote":
// return await createNote(event.arguments.note);
// case "updateNote":
// return await updateNote({ id: event.arguments.noteId, content: event.arguments.note.content});
// case "deleteNote":
// return await deleteNote(event.arguments.noteId);
// case "getNoteById":
// return await getNoteById(event.arguments.noteId);
default:
return null;
}
}
Ahmed Moaz Asif
03/21/2022, 5:12 AM.sst\artifacts\dev-ahmed-starlight-backend-AppSyncStack-AppSyncApi-Lambda_notes\src\functions\notes.js
if (alternateMethod || appRootPath == null) {
appRootPath = path.dirname(requireFunction.main.filename);
}
requireFunction is a function and so it can't read property filename of mainAhmed Moaz Asif
03/21/2022, 5:13 AMrequireFunction
var requireFunction = typeof __webpack_require__ === "function" || typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : require;
Frank
Frank
main
function inside ur stacks/index.ts
app.setDefaultFunctionProps({
bundle: {
nodeModules: ["typeorm"],
},
});
Frank
esbuild
.Frank
Ahmed Moaz Asif
03/24/2022, 6:47 AMAhmed Moaz Asif
03/24/2022, 6:47 AM