-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
Next.jsPredictionsRelated to Predictions categoryRelated to Predictions categorySSRIssues related to Server Side RenderingIssues related to Server Side Renderingfeature-requestRequest a new featureRequest a new feature
Description
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React, Next.js
Amplify APIs
Predictions
Amplify Categories
predictions
Environment information
System:
OS: macOS 11.3.1
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 268.66 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.0/bin/yarn
npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm
Browsers:
Brave Browser: 89.1.22.71
Chrome: 90.0.4430.93
Edge: 90.0.818.51
Firefox: 87.0
Firefox Developer Edition: 88.0
Safari: 14.1
npmGlobalPackages:
@aws-amplify/cli: 4.50.0
localtunnel: 2.0.1
npm: 6.14.11
serverless: 2.35.0
to: 0.2.9
update: 0.7.4
yarn: 1.22.10
Describe the bug
Using prediction
within the NextJS API routes (which run on NodeJS
) throws the following error FileReader is not defined
Expected behavior
Although I'm fully aware NextJS API routes are not supported, I think it would be a great addition.
Reproduction steps
Setup a simple NextJS environment with Amplify:
- Install NextJS
- Initialize Amplify
- Initialize Predictions
- Create a NextJS API route that uses predictions
- See error
Code Snippet
const response = await fetch(url)
const file = await response.blob()
const { text } = await Amplify.Predictions.identify({
text: {
source: {
file,
},
format: 'PLAIN',
},
})
Log output
(node:45356) UnhandledPromiseRejectionWarning: ReferenceError: FileReader is not defined
at /path/to/project/node_modules/@aws-amplify/predictions/lib/Providers/Utils.js:37:22
at new Promise (<anonymous>)
at Object.blobToArrayBuffer (/path/to/project/node_modules/@aws-amplify/predictions/lib/Providers/Utils.js:36:12)
at /path/to/project/node_modules/@aws-amplify/predictions/lib/Providers/AmazonAIIdentifyPredictionsProvider.js:112:25
at new Promise (<anonymous>)
at AmazonAIIdentifyPredictionsProvider.configureSource (/path/to/project/node_modules/@aws-amplify/predictions/lib/Providers/AmazonAIIdentifyPredictionsProvider.js:90:16)
at AmazonAIIdentifyPredictionsProvider.<anonymous> (/path/to/project/node_modules/@aws-amplify/predictions/lib/Providers/AmazonAIIdentifyPredictionsProvider.js:168:51)
at step (/path/to/project/node_modules/@aws-amplify/predictions/lib/Providers/AmazonAIIdentifyPredictionsProvider.js:57:23)
at Object.next (/path/to/project/node_modules/@aws-amplify/predictions/lib/Providers/AmazonAIIdentifyPredictionsProvider.js:38:53)
at fulfilled (/path/to/project/node_modules/@aws-amplify/predictions/lib/Providers/AmazonAIIdentifyPredictionsProvider.js:29:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:45356) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 9)
(node:45356) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
I wasn't sure if this was a bug report of a feature request, so my bad it it needed to be a feature request!
Metadata
Metadata
Assignees
Labels
Next.jsPredictionsRelated to Predictions categoryRelated to Predictions categorySSRIssues related to Server Side RenderingIssues related to Server Side Renderingfeature-requestRequest a new featureRequest a new feature