出于某种原因,大多数页面刷新会重新请求 bundle.js 文件,从本地主机下载大约需要 10-15-20 秒。这一切都来自本地主机,并且 bundle.js 文件大小约为 1mb。对这个文件的请求似乎只是爬行,一次加载几千字节。
一些观察:
经过一番挖掘,它似乎在从 __webpack_hmr 对服务器的初始调用中停滞不前,但我不确定这个调用是在调用 bundle.js 之后发生的。下面是服务器请求流的日志。
只有在具有超过一两个组件的页面上才会变慢,即。主页以外的任何内容。这暗示了它可能与热模块重新加载有关的想法。
请求日志:
-响应时间GET / = 609ms
- > GET / 200 647ms 2.55kb
< - GET /main.aafc9fb7f6a0c7f127edb04734d29547.css
- > GET /main.aafc9fb7f6a0c7f127edb04734d29547.css 200 17MS 3.43kb
< - /bundle.js
- > GET /bundle.js 200 18ms 1.29mb
<-- GET /__webpack_hmr
这是我的设置:
我正在尝试在生产服务器上设置我的网站,并且基本上在/system/core/CodeIgniter.php中的第291行崩溃:
//instantiate the requested controller
// Mark a start point so we can benchmark the controller
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
$CI = new $class();
Run Code Online (Sandbox Code Playgroud)
该类是“ auth”(来自tank_auth库),因此在“ $ CI = new auth();”上崩溃。
它不会产生错误(为什么?),仅显示空白页。所有这些在本地都可以正常工作。
有没有人有类似的问题?
所以我试图解决为什么CodeIgniter不会显示任何输出(除了404等).我已经检查了从错误登录php和apache和codeigniter到模块重写的所有内容.一切似乎配置得很好.
我开始深入研究CodeIgniter核心文件,并注意到它在下面的行上崩溃,试图实例化所请求的控制器类:
$class = $RTR->fetch_class();
$method = $RTR->fetch_method();
echo 'looking for class: ' . $class . '<br/>';
if(class_exists($class) == false) {
)
{
echo 'class does not exist: ' . $class;
show_404("{$class}/{$method}");
}
}
/*
* ------------------------------------------------------
* Is there a "pre_controller" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('pre_controller');
echo '<br/>after precontroller';
/*
* ------------------------------------------------------
* Instantiate the requested controller
* ------------------------------------------------------
*/
// Mark a start point so we can benchmark the controller
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
echo '<br/>before class …Run Code Online (Sandbox Code Playgroud) Hiyas.我有一个简单的应用程序,其中客户端期望作为结果的承诺,但在调用resolve()方法时,promise将继续返回undefined作为结果.
客户端代码:
UsersRepo.findOneAsync({id: id}).then(function(err, result) {
console.log("UserService promise resolution", err, result);
});
Run Code Online (Sandbox Code Playgroud)
对于错误和结果,它分别输出"null"和"undefined"
正在进行工作并返回承诺的代码:
findOneAsync: function(args) {
var where = ""; //omitted
var promise = new Promise(function(resolve, reject) {
db.query("Select * from users" + where + " limit 1", function(err, result) {
var res = { id: 1, username: 'username', firstName: 'First', lastName: 'Last' };
if(err != null) {
console.log("REJECT", err);
reject(err);
}
else {
console.log("RESOLVE", res);
resolve(null, res);
}
});
});
return promise;
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我只是为此测试返回一些静态数据('res'变量).在客户端代码中,控制台语句始终打印出:
UserService promise resolution null …Run Code Online (Sandbox Code Playgroud) 我遇到了一个奇怪的问题,其中$_GET(and $_REQUEST) 变量为空,即使正在传递参数。
我的PHP代码:
echo $_SERVER['REQUEST_URI'];
echo print_r($_REQUEST);
echo print_r($_GET);
Run Code Online (Sandbox Code Playgroud)
输出:
/service/getAllOrders?sortBy=date_created&sortDir=desc
Array()
Array()
Run Code Online (Sandbox Code Playgroud)
我正在使用 nginx 并将所有请求转发到 index.php。我的配置如下:
server {
listen 80;
server_name decaro.localhost;
root /Users/rweiss/Sites/decaro/LocalOrderWebsite;
#access_log /usr/local/etc/nginx/logs/default.access.log main;
location / {
add_header Cache-Control "no-cache, no-store";
include /usr/local/etc/nginx/conf.d/php-fpm;
try_files $uri $uri/ /index.php$args;
}
location /assets/ {
allow all;
}
location = /info {
allow 127.0.0.1;
deny all;
rewrite (.*) /.info.php;
}
error_page 404 /404.html;
error_page 403 /403.html;
}
Run Code Online (Sandbox Code Playgroud)
为什么?
我一直很难让子实体使用 REST api 自动工作。
我有一个基类:
class Block {
@PrimaryGeneratedColumn('uuid')
public id: string;
@Column()
public type: string;
}
Run Code Online (Sandbox Code Playgroud)
然后将其扩展到其他块类型,例如:
@Entity('sites_blocks_textblock')
class TextBlock extends Block {
@Column()
public text: string;
}
Run Code Online (Sandbox Code Playgroud)
我让每个块类型都有自己的实体,以便列可以正确序列化到数据库,并对每个属性进行验证。
所以...我有 10 多个块类型,并且我试图避免使用单独的控制器和 CRUD 端点来每个块类型。我只想要一个 BlockController、一个 /block 端点、POST 来创建,然后 PUT 到 /block/:id 上进行更新,这样它就可以从请求的“type”主体参数推断出块的类型。
问题是,在请求中,最后一个 @Body() 参数将不会验证(请求不会通过),除非我使用类型“any”...因为每个自定义块类型都传递它的额外/自定义属性。否则,我将不得不使用每个特定的 Block 子类作为参数类型,需要为每种类型提供自定义方法。
为了实现这一目标,我尝试使用自定义验证管道和泛型,我可以在其中查看传入的“类型”主体参数,并将传入数据强制转换或实例化为特定的块类型。
控制器处理程序:
@Post()
@UseGuards(PrincipalGuard)
public create(@Principal() principal: User,
@Param('siteId', ParseUUIDPipe) siteId: string,
@Body(new BlockValidationPipe()) blockCreate: any): Promise<Block> {
return this.blockService.create(principal.organization, siteId, blockCreate);
}
Run Code Online (Sandbox Code Playgroud)
BlockValidationPipe(这应该将传入数据对象转换为特定的块类型,然后验证它,以该类型返回传入数据对象):
@Injectable()
export class BlockValidationPipe implements PipeTransform<any> {
async …Run Code Online (Sandbox Code Playgroud) codeigniter ×2
node.js ×2
php ×2
bluebird ×1
generics ×1
get ×1
javascript ×1
koa ×1
localhost ×1
nestjs ×1
nginx ×1
promise ×1
typeorm ×1
typescript ×1
webpack ×1
webpack-hmr ×1