Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pha with data loader #6029

Merged
merged 8 commits into from
Mar 9, 2023
Merged

Conversation

chenjun1011
Copy link
Collaborator

如果 data loader 存在立即执行代码,增加保护措施,避免报错引起 Manifest 构建失败

const [appConfig, routesConfig, dataloaderConfig] = await Promise.all([getAppConfig(['phaManifest']), getRoutesConfig(), getDataloaderConfig()]);
const [appConfig, routesConfig] = await Promise.all([getAppConfig(['phaManifest']), getRoutesConfig()]);

let dataloaderConfig;
Copy link
Collaborator

Choose a reason for hiding this comment

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

如果被 catch 了,这个 dataloaderConfig 是一个 undefined,下面处理是否有兜底逻辑,默认给个控对象?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

应该是后续消费的地方,本身做了兼容的,效果等同于没有配 DataLoader

@chenjun1011 chenjun1011 added the need review Need Review label Mar 8, 2023
@answershuto
Copy link
Collaborator

CI 报错啦

@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2023

Codecov Report

Patch coverage: 68.75% and project coverage change: -0.03 ⚠️

Comparison is base (fa618ea) 82.07% compared to head (ee434c4) 82.05%.

Additional details and impacted files
@@               Coverage Diff                @@
##           release/next    #6029      +/-   ##
================================================
- Coverage         82.07%   82.05%   -0.03%     
================================================
  Files               197      197              
  Lines             18090    18132      +42     
  Branches           2361     2367       +6     
================================================
+ Hits              14848    14878      +30     
- Misses             3207     3219      +12     
  Partials             35       35              
Impacted Files Coverage Δ
packages/plugin-pha/src/constants.ts 70.58% <0.00%> (-3.10%) ⬇️
packages/ice/src/createService.ts 90.36% <100.00%> (+0.02%) ⬆️
packages/ice/src/types/plugin.ts 100.00% <100.00%> (ø)
packages/ice/src/utils/logger.ts 55.55% <100.00%> (+1.53%) ⬆️
packages/route-manifest/src/index.ts 90.30% <0.00%> (-1.34%) ⬇️
packages/route-manifest/src/routes.ts 94.93% <0.00%> (-0.04%) ⬇️
packages/ice/src/routes.ts 98.57% <0.00%> (-0.02%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

// dataLoader may have side effect code.
dataloaderConfig = await getDataloaderConfig();
} catch (err) {
logger.debug('PHA: getDataloaderConfig failed.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

logger.debug 是手动打开某个参数才会提示吗?不会透露给用户?

Copy link
Collaborator

Choose a reason for hiding this comment

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

建议是用 namespace,不要 PHA:

@@ -53,6 +53,9 @@ export type CreateLoggerReturnType = Pick<Consola, |
'debug' |
'trace'
>;

export type CreateLogger = (namespace?: ICELogNamespace) => CreateLoggerReturnType;

export function createLogger(namespace?: ICELogNamespace): CreateLoggerReturnType {
Copy link
Collaborator

Choose a reason for hiding this comment

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

如果是上面定义了 CreateLogger 的话,这里建议写成函数表达式

// dataLoader may have side effect code.
dataloaderConfig = await getDataloaderConfig();
} catch (err) {
logger.debug('PHA: getDataloaderConfig failed.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

建议是用 namespace,不要 PHA:

packages/plugin-pha/src/phaMiddleware.ts Outdated Show resolved Hide resolved
@answershuto answershuto merged commit 0c61f46 into release/next Mar 9, 2023
@answershuto answershuto deleted the fix-pha-with-data-loader branch March 9, 2023 11:53
@ClarkXia ClarkXia mentioned this pull request Mar 15, 2023
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need review Need Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants