Unable to start server
I upgraded re.pack to @4.0.0-rc.0 and i'm not able to start the server by running 'npx react-native webpack-start' again. The error i'm getting below;
error fastify-favicon: \C:\Users\directory\Documents\d\node_modules@callstack\repack-dev-server\dist\img\favicon.ico not found. Error: fastify-favicon: \C:\Users\directory\Documents\d\node_modules@callstack\repack-dev-server\dist\img\favicon.ico not found at ReadFileContext. (C:\Users\directory\Documents\d\node_modules\fastify-favicon\src\plugin.js:60:14) at ReadFileContext.callback (C:\Users\directory\Documents\d\node_modules\graceful-fs\graceful-fs.js:123:16) at FSReqCallback.readFileAfterOpen [as oncomplete] (node:fs:306:13)
what do i do
Thanks for helping
@omotayoR1 I have no access to Windows right now and have no way to check for a fix.
My best guess is that somehow path in C:\Users\directory\Documents\d\node_modules@callstack\repack-dev-server\dist\plugins\faviconPlugin.js evaluates incorrectly, you can try adjust it to see if it resolves this.
@omotayoR1 I have no access to Windows right now and have no way to check for a fix.
My best guess is that somehow path in
C:\Users\directory\Documents\d\node_modules@callstack\repack-dev-server\dist\plugins\faviconPlugin.jsevaluates incorrectly, you can try adjust it to see if it resolves this.
I checked the path mentioned and on line 24, it seems something is wrong there const fp = require('fastify-plugin')
What's the resolution please
Thanks for helping
@omotayoR1 could you provide a snippet? I see the file has only like 15 LOC
@omotayoR1 could you provide a snippet? I see the file has only like 15 LOC
/*
- Copyright 2018-2023 the original author or authors. *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
-
http://www.apache.org/licenses/LICENSE-2.0
*
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. */ 'use strict'
/**
- Plugin:
- this module exports the plugin as a function.
- @module plugin */
const fp = require('fastify-plugin') const pn = require('node:path') const fs = require('node:fs')
const iconNameDefault = 'favicon.ico'
/**
- Plugin implementation. *
- @param {!object} fastify Fastify instance
- @param {!object} options plugin configuration options
-
-
<li>path (string, default `__dirname`) for the folder containing the icon,</li> -
<li>name (string, default 'favicon.ico') for favicon file name,</li> -
<li>maxAge (number, default 86400) for cache duration in seconds for the image,</li>
ensureIsString(path, 'iconPath') ensureIsString(name, 'iconName') ensureIsInteger(maxAge, 'maxAge')
const icon = pn.join(path, name)
fs.readFile(icon, (err, faviconFile) => {
if (err) {
if (err.code === 'ENOENT') {
done(new Error(fastify-favicon: ${icon} not found))
return
}
done(new Error(`fastify-favicon: Could not load ${icon}`))
return
}
fastify.get(`/${name}`, faviconRequestHandler(faviconFile))
done()
})
/**
- Factory for the request handler for the favicon. *
- @param {!object} file the icon file to send in the response
- @return {function} the handler function, preconfigured with plugin settings and the file to send *
- @inner
*/
function faviconRequestHandler (file) {
const cacheHeader =
max-age=${maxAge}return function handler (_fastifyRequest, fastifyReply) { fastifyReply .header('cache-control', cacheHeader) .type('image/x-icon') .send(file) } } }
// utility functions
function ensureIsString (arg, name) {
if (arg !== null && typeof arg !== 'string') {
throw new TypeError(The argument '${name}' must be a string, instead got a '${typeof arg}')
}
}
function ensureIsInteger (arg, name) {
if (arg !== null && typeof arg !== 'string' && Number.isFinite(arg) === false && Number.isInteger(arg) === false) {
throw new TypeError(The argument '${name}' must be an integer)
}
}
module.exports = fp(fastifyFavicon, { fastify: '4.x', name: 'fastify-favicon' })
@omotayoR1 FYI, I should be able to investigate this on Windows by the end of the week
@omotayoR1 FYI, I should be able to investigate this on Windows by the end of the week
Okay
Thanks for helping
@jbroma have you been able to investigate this ?
@omotayoR1 FYI, I should be able to investigate this on Windows by the end of the week
@paaber yes, the investigation is ongoing and we're working on a fix together with @szymonrybczak
@omotayoR1 @paaber we've just released @callstack/repack 4.0.0-rc.1, your issues should be resolved now :)
Btw, you can now install Re.Pack in new projects with custom version like this:
npx @callstack/repack-init@rc --custom-version 4.0.0-rc.1
@omotayoR1 @paaber we've just released
@callstack/repack4.0.0-rc.1, your issues should be resolved now :)Btw, you can now install Re.Pack in new projects with custom version like this:
npx @callstack/repack-init@rc --custom-version 4.0.0-rc.1
Thanks for helping. The server starts now and builds successfully but it stops bundling at some point and it throws this error
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({})
at Compiler.emit (node:events:508:17)
at Worker.
Node.js v21.4.0
Please help me look into it
Thanks
@omotayoR1 please open a new issue