Skip to content

Commit

Permalink
fix: add back missing aws-sdk dep warning (#3384)
Browse files Browse the repository at this point in the history
* fix: add back missing aws-sdk dep warning

* fix: preoprty of undefined error in detectAwsSdkError

Co-authored-by: ehmicky <ehmicky@users.noreply.github.com>
  • Loading branch information
tinfoil-knight and ehmicky committed Sep 24, 2021
1 parent 92cfa0a commit 03a8d1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/lib/functions/synchronous.js
Expand Up @@ -2,6 +2,8 @@ const { Buffer } = require('buffer')

const { NETLIFYDEVERR } = require('../../utils/logo')

const { detectAwsSdkError } = require('./utils')

const addHeaders = (headers, response) => {
if (!headers) {
return
Expand Down Expand Up @@ -36,6 +38,8 @@ const handleSynchronousFunction = function (err, result, response) {
const formatLambdaLocalError = (err) => `${err.errorType}: ${err.errorMessage}\n ${err.stackTrace.join('\n ')}`

const handleErr = function (err, response) {
detectAwsSdkError({ err })

response.statusCode = 500
const errorString = typeof err === 'string' ? err : formatLambdaLocalError(err)
response.end(errorString)
Expand Down
5 changes: 3 additions & 2 deletions src/lib/functions/utils.js
@@ -1,5 +1,6 @@
const chalk = require('chalk')

const { warn } = require('../../utils/command-helpers')
const { getLogMessage } = require('../log')

const BASE_64_MIME_REGEXP = /image|audio|video|application\/pdf|application\/zip|applicaton\/octet-stream/i
Expand All @@ -10,8 +11,8 @@ const DEFAULT_LAMBDA_OPTIONS = {

const SECONDS_TO_MILLISECONDS = 1000

const detectAwsSdkError = ({ error, warn }) => {
const isAwsSdkError = error.errorMessage && error.errorMessage.includes("Cannot find module 'aws-sdk'")
const detectAwsSdkError = ({ error }) => {
const isAwsSdkError = error && error.errorMessage && error.errorMessage.includes("Cannot find module 'aws-sdk'")

if (isAwsSdkError) {
warn(getLogMessage('functions.missingAwsSdk'))
Expand Down

1 comment on commit 03a8d1e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

Package size: 352 MB

Please sign in to comment.