-
Notifications
You must be signed in to change notification settings - Fork 247
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
Amplify Fails to Configure - WorkerBeeExceptionImpl #5190
Comments
@CarlosEspinozaMaruri I found this thread from another package The solution was described: _[ Service ] Include drive letter in path when launching DDS snapshot The previous logic for building the path to dds.dart.snapshot would result \path\to\dart-sdk\bin\dds.dart.snapshot This works most of the time since a leading slash is treated as a reference This change uses the File(...) APIs from dart:io to build the path rather than TEST=N/A, not reproducible without a second Windows drive_ |
@CarlosEspinozaMaruri - Thanks for providing the additional info. The json file appears to be mostly valid, but there are additional characters at the end of the file. The additional characters look like they are json fragments. It isn't clear to me how this would occur. One thought I had was that multiple simultaneous writes may somehow result in a fragment being written the the file, although if that were the case I would think that would be a bug in the Dart File APIs. I am going to try to see if I can reproduce this on a windows device though. @ftauro082799 - I don't think the issue you linked is related. It happens to be the same exception (FormatException: Unexpected character), but this could occur for many reasons. Let me know if I am missing something. If you are also experiencing this issue, sharing the exception/stacktrace/logs along with any reproduction in you have would be helpful. |
@Jordan-Nelson I figured, but it was one of the few other threads I found with this issue so figured I would link if it was helpful. I am experiencing this issue as well. Here is a timeline of what I found:
flutter: [I] AuthService, configureCognitoPlugin, amplify plugins added ***Note: Even when building my app on the original PC, which works fine, I cannot run the compiled app on my new PC where this error is occurring This error occurred upon calling this line. The json encode is NOT the part causing issues
This is the amplify config being encoded and sent in: { Within the configure function of the AmplifyClass, I found that the error occurs in the _configurePlugins function:
Specifically, where the plugin.configure is called during the mapping: for (final category in sortedCategories) {
final plugins = categories[category]!.plugins;
await Future.wait(
eagerError: true,
plugins.map(
(plugin) => plugin.configure(
config: config,
authProviderRepo: authProviderRepo,
),
),
);
} My configuration which is being sent into the for loop above is shown below (with sensitive info being replaced with x's, of course): Config is AmplifyOutputs { I only have one plugin which is being configured, and it fails during the first loop as plugin.configure is called. After fully reinstalling both the dart and flutter sdk, and verifying that everything else on the new PC is set up properly, the error continues to occur. |
@CarlosEspinozaMaruri I believe I was able to reproduce the issue your are experiencing. Based on the discussion on dart-lang/sdk#36087 it seems that parallel unawaited calls to File APIs in not safe (at least on Windows). I have raised a PR to address this. I will let you know when it is released. |
@Jordan-Nelson - could you explain why this happens on some Windows PCs on not others? |
@pieterbergmans I do not know that this is only reproducible on some Windows machines. It may be reproducible on all Windows machines. Have you been able to consistently reproduce this on some machines and not others? If so, can you share the reproduction steps you are following? To reproduce this consistently I had to write a test that performs 1,000 parallel operations. With 100 parallel operations it was only reproducible some of the time. Secure Storage will only perform a much smaller number of parallel operations (maybe 10-20). I think this issue would rarely occur with that number of parallel ops. This would explain why this issue was not easily reproducible under normal use. It is possible that the file system APIs behave differently on different Windows machines. Since this is a race condition, it is also possible this issue is more likely to occur on machines that process the operations either faster or slower. |
@Jordan-Nelson - I work with @ftauro082799 so I’ve been watching all this go down. His new PC (base speed: 2.40GHz; cores: 14; L1, L2, L3 cache: 1.2MB, 11.5MB, 24.0MB) doesn’t work at all. His old PC (base speed: 2.30GHz; cores: 14; L1, L2, L3 cache: 1.2MB, 11.5MB, 24.0MB) never had an issue. I tested on a third PC (base speed: 1.10GHz; cores: 10; L1, L2, L3 cache: 928KB, 6.5MB, 12.0MB) and it worked just fine. To your point about it being a race condition and that the speed of the PC could impact it - as you can see, Fred’s new PC is the fastest and it doesn’t work. But, it doesn’t seem that much faster than his old. We’re looking forward to your PR. Thanks so much for helping us out. We’ll provide feedback after we try out your changes. |
I see. Thanks for that context. It is possible that you are facing a different issue, but I am not sure. You can test this PR by adding the following to your pubspec.yaml and then re-installing packages (pub get / pub upgrade) # add after dependencies/dev_dependencies
dependency_overrides:
amplify_secure_storage_dart:
git:
url: https://github.com/aws-amplify/amplify-flutter
ref: fix/secure_storage/process-events
path: packages/secure_storage/amplify_secure_storage_dart |
@Jordan-Nelson I just tested the PR and it seemed to have fixed my issue. I also now do not need to have the override enabled after running it once and it clearing the supposedly corrupt file. It will be interesting if it happens again. Thank you! |
@ftauro082799 thanks for letting me know |
I'm going to close this issue as the fix has been released in 2.4.0 version. If you see otherwise or have additional questions, please open a new issue. |
Description
This issue is a duplicate of this that was closed due to lack of information. I have managed to obtain the requested JSON files and attach them below.
When attempting to configure Amplify using Amplify.configure(), the following exception is being thrown:
Exception:
Stacktrace:
Corrupted json files:
This seems to only happen on Windows devices. I have successfully replicated the error in production on 4 devices belonging to different clients. Despite efforts, I have been unable to reproduce the error in our development environment. However, it has come to my attention that this error occurs in installations approximately 2 or more days old. Furthermore, it is noteworthy that reinstalling the application from the Windows Store resolves the issue, suggesting potential file corruption.
Notes:
String.fromEnvironment('variable_name') to access private keys in environment variables.
Categories
Steps to Reproduce
Screenshots
No response
Platforms
Flutter Version
3.22.2
Amplify Flutter Version
2.1.0
Deployment Method
Amplify CLI
Schema
No response
The text was updated successfully, but these errors were encountered: