[Error: ENOENT: no such file or directory, open 'C:\tmp\elliott1695549520613.pdf'] {
Saunakghosh10 opened this issue · 11 comments
facing issue with this..
[Error: ENOENT: no such file or directory, open 'C:\tmp\elliott1695549520613.pdf'] {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\tmp\elliott1695549520613.pdf'
}
- error uncaughtException: [Error: ENOENT: no such file or directory, open 'C:\tmp\elliott1695549520613.pdf'] {
digest: undefined
}
TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at async invokeRequest (C:\Users\sauna\Downloads\chatpdf-yt-main (1)\chatpdf-yt-main\node_modules\next\dist\server\lib\server-ipc\invoke-request.js:17:12)
at async invokeRender (C:\Users\sauna\Downloads\chatpdf-yt-main (1)\chatpdf-yt-main\node_modules\next\dist\server\lib\router-server.js:254:29)
at async handleRequest (C:\Users\sauna\Downloads\chatpdf-yt-main (1)\chatpdf-yt-main\node_modules\next\dist\server\lib\router-server.js:447:24)
at async requestHandler (C:\Users\sauna\Downloads\chatpdf-yt-main (1)\chatpdf-yt-main\node_modules\next\dist\server\lib\router-server.js:464:13)
at async Server. (C:\Users\sauna\Downloads\chatpdf-yt-main (1)\chatpdf-yt-main\node_modules\next\dist\server\lib\start-server.js:117:13) {
cause: HeadersTimeoutError: Headers Timeout Error
at Timeout.onParserTimeout [as callback] (C:\Users\sauna\Downloads\chatpdf-yt-main (1)\chatpdf-yt-main\node_modules\next\dist\compiled\undici\index.js:1:62578)
at Timeout.onTimeout [as _onTimeout] (C:\Users\sauna\Downloads\chatpdf-yt-main (1)\chatpdf-yt-main\node_modules\next\dist\compiled\undici\index.js:2:269659)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7) {
code: 'UND_ERR_HEADERS_TIMEOUT'
}
}
pls tell what to do
I'm having the same problem, after i upload the pdf i get this message, and no redirect to view the pdf file
Same issue here. PDF appears in AWS but then nothing else happens.
Actually try changing the folder in the file_name to /temp/... instead of /tmp/.
Seemed to fix it on my Windows PC.
The following works for Windows.
Otherwise, run your file in WSL, since the deployment will be on linux
// import node:os
let file_name;
if (os.platform() === "win32") {
file_name = `C:\\Users\\${
os.userInfo().username
}\\AppData\\Local\\Temp\\pdf-${Date.now()}.pdf`;
} else {
file_name = `/tmp/pdf-${Date.now()}.pdf`;
}
none of these solved this issue, did it solved for anyone else
The following works for Windows. Otherwise, run your file in WSL, since the deployment will be on linux
// import node:os let file_name; if (os.platform() === "win32") { file_name = `C:\\Users\\${ os.userInfo().username }\\AppData\\Local\\Temp\\pdf-${Date.now()}.pdf`; } else { file_name = `/tmp/pdf-${Date.now()}.pdf`; }
thanks... its working
none of these solved this issue, did it solved for anyone else
your should try this.. its working...
// import os from "os";
let file_name;
if (os.platform() === "win32") {
file_name = C:\\Users\\${ os.userInfo().username }\\AppData\\Local\\Temp\\pdf-${Date.now().toString()}.pdf
;
} else {
file_name = /tmp/pdf-${Date.now()}.pdf
;
}
This pull request will solve the problem for anyone who needs it, especially for deployment on Vercel.
#36
Hope it helps
Hey guys i have found a simple solution for this..
While i was debugging this Axios error: internal server error 500 :
IF you notice your concole in code editor there might be written file/module not found error.
Solution:
When you are trying to upload a File....
Check if the file is successfully uploaded to S3. If yes, then your connection with S3 is all good and UploadtoS3() function has no issues.
Now, check if you follow the code of route.ts. It calls the function loads3intoPinecone() which takes us to pinecone.ts.
Now in pinecone.ts under the method loads3intoPinecone(), the method downloadfrons3 is called which helps us to download our document from S3.
This takes us s3-server.ts file , here we are using fs module to write our downloaded file into a tmp file.
fs.writeFileSync(file_name, obj.Body as Buffer)
**i suggest try cosole.log(file_name) tocheck if you are getting the file_name ** if not which was in my case you can follow the next step.
Now , As the file_name is not available since the module/file is not downloaded from s3 a server-side error is poping up and also module not found error.
Finally, To fix this issue, you can try creating the /tmp directory manually and setting the correct permissions to make it writable. For this-
Go to the folder of your Project
NOTE: This is for windows
open the path in terminal and type the following command
mkdir /tmp
icacls C:\tmp /grant Everyone:F
Solve this by creating a file and folder :
import path from 'path'
// Create directory
const tmpDir = '/tmp' // Update this to the appropriate directory if needed
// Check if the directory exists, if not, create it
if (!fs.existsSync(tmpDir)) {
fs.mkdirSync(tmpDir)
}
// const file_name = `/tmp/elliott${Date.now().toString()}.pdf`;
const file_name = path.join(
tmpDir,
`chatpdf-${Date.now().toString()}.pdf`
)