(0.60.4) `sst start` boots up as per normal, but a...
# help
d
(0.60.4)
sst start
boots up as per normal, but all functions called through API routes (https) throw error
"Runtime.HandlerNotFound: /home/dkershner/repos/global-api-devops/.sst/artifacts/157a4603/src/api/health/get.default is not a function"
The file at that location appears to exist and contain uglified, but valid, code... I have tested 2 apps, and this persists to both.
My console also isnt working, so I cannot try another method of invocation.
I get the same error if I connect locally, then go into the AWS console and manually invoke the function.
t
Is this with esm turned on?
d
no, the only difference is that I updated CDK and SST to the latest
t
can you send me the code in "Runtime.HandlerNotFound: /home/dkershner/repos/global-api-devops/.sst/artifacts/157a4603/src/api/health/get.default is not a function"
d
its short and I dont mind folks seeing, since there is nothing in it
Copy code
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, copyDefault, desc) => {
  if (module2 && typeof module2 === "object" || typeof module2 === "function") {
    for (let key of __getOwnPropNames(module2))
      if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
        __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
  }
  return target;
};
var __toCommonJS = /* @__PURE__ */ ((cache) => {
  return (module2, temp) => {
    return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
  };
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);

// src/api/health/get.ts
var get_exports = {};
__export(get_exports, {
  default: () => get_default
});
var handler = async () => {
  return {
    statusCode: 200,
    body: "OK"
  };
};
var get_default = handler;
module.exports = __toCommonJS(get_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {});
//# sourceMappingURL=get.js.map
t
how are you exporting the handler in the source?
is it a default export?
d
correct
Copy code
import { APIGatewayProxyHandlerV2 } from "aws-lambda";

const handler: APIGatewayProxyHandlerV2 = async () => {
    return {
        statusCode: 200,
        body: "OK",
    };
};

export default handler;
t
ah this may be what doesn't work now with the new runtime updates, I didn't think was ever supported
typically people do
export handler
but let me see if I can get defaults working again
d
hmmm...its just a name seemingly... (
default
vs
handler
)
ill try named export
t
The runtime changes use
import
instead of
require
and I suspect
import
works differently and is conflicting with that ugly transpiled code
d
oh, in that case it might, but I think you can still import default as named, like
import { default } from "...";
you are correct, it is something to do with default exporting
are you guys using
nodejs-lambda
under the hood? Would the problem be there?
doesnt look like it.
t
I'm going to try and recreate the issue shortly - it's a combination of esbuild's output + aws-lambda-ric
d
note that this is only locally, the functions actually work out in the wild (deployed)
t
yeah that makes sense because we're using a forked version of the production runtime
d
FWIW I just upgraded SST and CDK and am getting the same error. This is what my source export is:
export const handler = server.createHandler();
and this is what it looks like in the artifacts folder
Copy code
var handler = server.createHandler();
module.exports = __toCommonJS(api_exports);
Error message is:
Copy code
{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Runtime.HandlerNotFound: /Users/danielwise/bwcode/rmw-sst-app/.sst/artifacts/0fa3d328/src/api.handler is undefined or not exported"
t
I'm working through this now, a quick workaround is to use named exports
if you want the fix asap you can add @serverless-stack-slack/aws-lambda-ric@2.0.11 to your deps
Otherwise we'll be doing a release soon
d
thanks for your help!
d
Indeed, thanks Dax.