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: data race writing on setting file #7475

Merged
merged 16 commits into from
May 6, 2021
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
4 changes: 2 additions & 2 deletions Composer/packages/server/src/models/bot/botProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ export class BotProject implements IBotProject {
// if endpointKey has not been set, migrate old key to new key
if (!settings.qna.endpointKey) {
settings.qna.endpointKey = settings.qna.endpointkey;
delete settings.qna.endpointkey;
await this.updateEnvSettings(settings);
}
delete settings.qna.endpointkey;
await this.updateEnvSettings(settings);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reduce unnecessary write on settings


// set these after migrating qna settings to not write them to storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class DefaultSettingManager extends FileSettingManager {
maxImbalanceRatio: -1,
},
skill: {},
skillConfiguration: {},
defaultLanguage: 'en-us',
languages: ['en-us'],
customFunctions: [],
Expand Down
4 changes: 2 additions & 2 deletions extensions/packageManager/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export default async (composer: IExtensionRegistration): Promise<void> => {
newlyInstalledPlugin &&
!currentProject.settings.runtimeSettings?.components?.find((p) => p.name === newlyInstalledPlugin.name)
) {
const newSettings = currentProject.settings;
const newSettings = await currentProject.getEnvSettings();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

During package fetch, settings can be expired, get latest before modify it.

if (!newSettings.runtimeSettings) {
newSettings.runtimeSettings = {
components: [],
Expand Down Expand Up @@ -475,7 +475,7 @@ export default async (composer: IExtensionRegistration): Promise<void> => {

// update the settings.components array
if (currentProject.settings.runtimeSettings?.components?.find((p) => p.name === packageName)) {
const newSettings = currentProject.settings;
const newSettings = await currentProject.getEnvSettings();
newSettings.runtimeSettings.components = newSettings.runtimeSettings.components.filter(
(p) => p.name !== packageName
);
Expand Down