Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/constant.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const CONTEXT = 'FC-DEPLOY';

export const useFcBackend = process.env.BUILD_IMAGE_ENV === 'fc-backend';

export const useBaseUploadCodeSize = 50 * 1024 * 1024;
20 changes: 15 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,11 +958,21 @@ export default class FcDeployComponent {
retry(ex);
}
// 代码包问题给出方案跳出
if (/^the size of file \d+ could not greater than \d+$/.test(ex.message)) {
throw new core.CatchableError(
ex.message,
'For large code package upload, please refer to https://github.com/awesome-fc/fc-faq/blob/main/docs/大代码包部署的实践案例.md',
);
const apiUnzipMaximumError = /^the size of file \d+ could not greater than \d+$/.test(ex.message);
const uploadMaximumError = /payload size exceeds maximum allowed size/.test(ex.message);
if (apiUnzipMaximumError || uploadMaximumError) {
logger.debug('Deployment failed due to code package issues');
const useWithoutCodeLimit = _.get(fcBaseComponentInputs, 'props.function.withoutCodeLimit');
if (useWithoutCodeLimit) {
throw new core.CatchableError(
ex.message,
'For large code package upload, please refer to https://github.com/awesome-fc/fc-faq/blob/main/docs/大代码包部署的实践案例.md',
);
}
logger.debug('Attempt to redeploy using OSS upload method');
_.set(fcBaseComponentInputs, 'props.function.withoutCodeLimit', true);
retry(ex);
return;
}
// 权限问题或者日志 auto 的问题直接跳出
if (ex.code === 'AccessDenied' || (logConfigIsAuto && isSlsNotExistException(ex))) {
Expand Down
9 changes: 5 additions & 4 deletions src/lib/component/fc-base-sdk/command/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import logger from '../../../../common/logger';
import { getFcEndpoint } from '../../../profile';
import { writeCreatCache } from '../../../utils/write-creat-cache';
import { ENABLE_EB_TRIGGER_HEADER } from '../constants';
import { useFcBackend } from '../../../../constant';
import { useFcBackend, useBaseUploadCodeSize } from '../../../../constant';

export default class Component {
static configPath;
Expand Down Expand Up @@ -259,8 +259,9 @@ export default class Component {

if (!onlyDeployConfig) {
if (filename) {
if (fs.statSync(filename).size > 52428800 || useFcBackend) {
functionConfig.withoutCodeLimit = true;
const needUseWithoutCodeLimit = functionConfig.withoutCodeLimit || fs.statSync(filename).size > useBaseUploadCodeSize || useFcBackend;
if (needUseWithoutCodeLimit) {
functionConfig.withoutCodeLimit = needUseWithoutCodeLimit;
functionConfig.code = {
zipFile: filename,
};
Expand All @@ -275,7 +276,7 @@ export default class Component {
ossObjectName: ossKey,
};
}

logger.debug(`Using withoutCodeLimit: ${functionConfig.withoutCodeLimit}`);
if (runtime === 'custom-container') {
if (!isCustomContainerConfig(customContainerConfig)) {
throw new Error(
Expand Down